class VideoTag extends BaseTag implements VideoTransformationInterface

Generates an HTML <video> tag with specified attributes, containing <source> tags for the transformation URLs.

For example:

<video poster="https://res.cloudinary.com/demo/video/upload/dog.jpg">
<source src="https://res.cloudinary.com/demo/video/upload/vc_h265/dog.mp4" type="video/mp4; codecs=hev1">
<source src="https://res.cloudinary.com/demo/video/upload/vc_vp9/dog.webm" type="video/webm; codecs=vp9">
<source src="https://res.cloudinary.com/demo/video/upload/vc_auto/dog.mp4" type="video/mp4">
<source src="https://res.cloudinary.com/demo/video/upload/vc_auto/dog.webm" type="video/webm">
</video>

Properties

Configuration $config from BaseTag

Methods

videoPosterFormat(string $format)

Image format of the video poster.

useFetchFormat(bool $useFetchFormat = true)

Use fetch format transformation ("f_") instead of file extension.

__construct(string|Video $video, array|null $sources = null, Configuration|string|array|null $configuration = null)

VideoTag constructor.

configuration(Configuration|string|array|null $configuration)

Sets the configuration.

importConfiguration(Configuration|string|array|null $configuration)

Imports (merges) the configuration.

addClass(string|array $class)

Adds a tag class.

setClass(string|array $class)

Resets tag classes and sets the specified one.

setAttribute(string $key, mixed $value = null)

Sets tag attribute.

setAttributes(array $attributes)

Sets (multiple) tag attributes.

deleteAttribute(string $key)

Deletes tag attribute.

addContent(mixed $content, mixed $key = null)

Adds tag content.

setContent(mixed $content)

Sets the content of the tag to the specified one.

serialize()

Serializes the tag to string.

serializeContent(array $additionalContent = [], bool $prependAdditionalContent = false)

Serializes the tag content.

serializeAttributes(array $attributes = [])

Serializes the tag attributes.

toTag()

Serializes the tag to string.

__toString()

Serializes the tag to string.

upload(string|mixed $publicId, Configuration|string|array|null $configuration = null)

Creates the video tag of the uploaded video.

fetch(string $url, Configuration|string|array|null $configuration = null)

Creates the video tag of the fetched (remote) video URL.

cdnSubdomain(bool $cdnSubdomain = true)

Whether to automatically build URLs with multiple CDN sub-domains.

secureCdnSubdomain(bool $secureCdnSubdomain = true)

Whether to use secure CDN sub-domain.

cname(string $cname)

The custom domain name to use for building HTTP URLs.

secure(bool $secure = true)

Force HTTPS URLs for resources even if they are embedded in non-secure HTTP pages.

secureCname(string $secureCname)

The domain name of the CDN distribution to use for building HTTPS URLs.

privateCdn(bool $privateCdn = true)

Set this parameter to true if you are an Advanced plan user with a private CDN distribution.

signUrl(bool $signUrl = true)

Set to true to create a signed Cloudinary URL.

longUrlSignature(bool $longUrlSignature = true)

Setting both this and signUrl to true will sign the URL using the first 32 characters of a SHA-256 hash.

shorten(bool $shorten = true)

Set to true to use shorten asset type.

useRootPath(bool $useRootPath = true)

Set to true to omit type and resource_type in the URL.

forceVersion(bool $forceVersion = true)

Set to false to omit default version string for assets in folders in the delivery URL.

analytics(bool $analytics = true)

Set to false to omit analytics.

defaultVideoSources()

The default video sources of the video tag.

video(mixed $video, Configuration $configuration = null)

Sets the video of the tag.

sources(array $sourcesDefinitions)

Sets the tag sources.

fromParams(string $source, array $params = [])

Creates a new video tag from the provided source and an array of parameters.

fallback(string $content)

Sets the fallback content.

poster(string|Image|ImageTransformation $poster)

Sets the poster attribute.

jsonSerialize()

Serializes to json.

addTransformation(CommonTransformation $transformation)

Adds (appends) a transformation.

addAction(BaseAction|BaseQualifier|mixed $action)

Adds (chains) a transformation action.

Details

$this videoPosterFormat(string $format)

Image format of the video poster.

Parameters

Name Type Description
$format string Image format.

Return Value

$this

$this useFetchFormat(bool $useFetchFormat = true)

Use fetch format transformation ("f_") instead of file extension.

Parameters

Name Type Description
$useFetchFormat bool

Return Value

$this

__construct(string|Video $video, array|null $sources = null, Configuration|string|array|null $configuration = null)

VideoTag constructor.

Parameters

Name Type Description
$video string|Video The public ID or Video instance.
$sources array|null The tag sources definition.
$configuration Configuration|string|array|null The Configuration source.

Configuration configuration(Configuration|string|array|null $configuration)

Sets the configuration.

Parameters

Name Type Description
$configuration Configuration|string|array|null The Configuration source.

Return Value

Configuration

BaseTag importConfiguration(Configuration|string|array|null $configuration)

Imports (merges) the configuration.

Parameters

Name Type Description
$configuration Configuration|string|array|null The Configuration source.

Return Value

BaseTag

BaseTag addClass(string|array $class)

Adds a tag class.

Parameters

Name Type Description
$class string|array The class to add.

Return Value

BaseTag

BaseTag setClass(string|array $class)

Resets tag classes and sets the specified one.

Parameters

Name Type Description
$class string|array The class to set.

Return Value

BaseTag

BaseTag setAttribute(string $key, mixed $value = null)

Sets tag attribute.

Parameters

Name Type Description
$key string The attribute name.
$value mixed The attribute value.

Return Value

BaseTag

BaseTag setAttributes(array $attributes)

Sets (multiple) tag attributes.

Parameters

Name Type Description
$attributes array The attributes to set.

Return Value

BaseTag

BaseTag deleteAttribute(string $key)

Deletes tag attribute.

Parameters

Name Type Description
$key string The name of the attribute to delete.

Return Value

BaseTag

$this addContent(mixed $content, mixed $key = null)

Adds tag content.

Parameters

Name Type Description
$content mixed The content value.
$key mixed Optional. Used for uniqueness.

Return Value

$this

BaseTag setContent(mixed $content)

Sets the content of the tag to the specified one.

Parameters

Name Type Description
$content mixed The content of the tag.

Return Value

BaseTag

string serialize()

Serializes the tag to string.

Return Value

string

string serializeContent(array $additionalContent = [], bool $prependAdditionalContent = false)

Serializes the tag content.

Parameters

Name Type Description
$additionalContent array The additional content.
$prependAdditionalContent bool Whether to prepend additional content (instead of append).

Return Value

string

string serializeAttributes(array $attributes = [])

Serializes the tag attributes.

Parameters

Name Type Description
$attributes array Optional. Additional attributes to add without affecting the tag state.

Return Value

string

string toTag()

Serializes the tag to string.

Return Value

string

string __toString()

Serializes the tag to string.

Return Value

string

static VideoTagDeliveryTypeTrait upload(string|mixed $publicId, Configuration|string|array|null $configuration = null)

Creates the video tag of the uploaded video.

Parameters

Name Type Description
$publicId string|mixed The public ID of the asset.
$configuration Configuration|string|array|null The Configuration source.

Return Value

VideoTagDeliveryTypeTrait

static VideoTagDeliveryTypeTrait fetch(string $url, Configuration|string|array|null $configuration = null)

Creates the video tag of the fetched (remote) video URL.

Parameters

Name Type Description
$url string The URL of the remote video.
$configuration Configuration|string|array|null The Configuration source.

Return Value

VideoTagDeliveryTypeTrait

$this cdnSubdomain(bool $cdnSubdomain = true)

Whether to automatically build URLs with multiple CDN sub-domains.

Parameters

Name Type Description
$cdnSubdomain bool

Return Value

$this

See also

https://cloudinary.com/documentation/advanced_url_delivery_options#multiple_sub_domains

$this secureCdnSubdomain(bool $secureCdnSubdomain = true)

Whether to use secure CDN sub-domain.

Parameters

Name Type Description
$secureCdnSubdomain bool

Return Value

$this

$this cname(string $cname)

The custom domain name to use for building HTTP URLs.

Relevant only for Advanced plan users that have a private CDN distribution and a custom CNAME.

Parameters

Name Type Description
$cname string

Return Value

$this

See also

https://cloudinary.com/documentation/advanced_url_delivery_options#private_cdns_and_cnames

$this secure(bool $secure = true)

Force HTTPS URLs for resources even if they are embedded in non-secure HTTP pages.

Parameters

Name Type Description
$secure bool

Return Value

$this

$this secureCname(string $secureCname)

The domain name of the CDN distribution to use for building HTTPS URLs.

Relevant only for Advanced plan users that have a private CDN distribution.

Parameters

Name Type Description
$secureCname string The CNAME for secure (https) URLs.

Return Value

$this

See also

https://cloudinary.com/documentation/advanced_url_delivery_options#private_cdns_and_cnames

$this privateCdn(bool $privateCdn = true)

Set this parameter to true if you are an Advanced plan user with a private CDN distribution.

Parameters

Name Type Description
$privateCdn bool

Return Value

$this

See also

https://cloudinary.com/documentation/advanced_url_delivery_options#private_cdns_and_cnames

$this signUrl(bool $signUrl = true)

Set to true to create a signed Cloudinary URL.

Parameters

Name Type Description
$signUrl bool

Return Value

$this

$this longUrlSignature(bool $longUrlSignature = true)

Setting both this and signUrl to true will sign the URL using the first 32 characters of a SHA-256 hash.

Parameters

Name Type Description
$longUrlSignature bool

Return Value

$this

See also

https://cloudinary.com/documentation/advanced_url_delivery_options#generating_delivery_url_signatures

$this shorten(bool $shorten = true)

Set to true to use shorten asset type.

Parameters

Name Type Description
$shorten bool

Return Value

$this

$this useRootPath(bool $useRootPath = true)

Set to true to omit type and resource_type in the URL.

Parameters

Name Type Description
$useRootPath bool

Return Value

$this

See also

https://cloudinary.com/documentation/advanced_url_delivery_options#root_path_urls

$this forceVersion(bool $forceVersion = true)

Set to false to omit default version string for assets in folders in the delivery URL.

Parameters

Name Type Description
$forceVersion bool

Return Value

$this

$this analytics(bool $analytics = true)

Set to false to omit analytics.

Parameters

Name Type Description
$analytics bool Whether to include analytics.

Return Value

$this

static array defaultVideoSources()

The default video sources of the video tag.

Return Value

array

VideoTag video(mixed $video, Configuration $configuration = null)

Sets the video of the tag.

Parameters

Name Type Description
$video mixed The public ID or the Video asset.
$configuration Configuration The configuration instance.

Return Value

VideoTag

$this sources(array $sourcesDefinitions)

Sets the tag sources.

Parameters

Name Type Description
$sourcesDefinitions array The definitions of the sources.

Return Value

$this

static VideoTag fromParams(string $source, array $params = [])

Creates a new video tag from the provided source and an array of parameters.

Parameters

Name Type Description
$source string The public ID of the asset.
$params array The asset parameters.

Return Value

VideoTag

$this fallback(string $content)

Sets the fallback content.

Parameters

Name Type Description
$content string The fallback content.

Return Value

$this

$this poster(string|Image|ImageTransformation $poster)

Sets the poster attribute.

Parameters

Name Type Description
$poster string|Image|ImageTransformation The poster image.

Return Value

$this

mixed jsonSerialize()

Serializes to json.

Return Value

mixed

VideoTag addTransformation(CommonTransformation $transformation)

Adds (appends) a transformation.

Appended transformation is nested.

Parameters

Name Type Description
$transformation CommonTransformation The transformation to add.

Return Value

VideoTag

VideoTag addAction(BaseAction|BaseQualifier|mixed $action)

Adds (chains) a transformation action.

Parameters

Name Type Description
$action BaseAction|BaseQualifier|mixed The transformation action to add. If BaseQualifier is provided, it is wrapped with action.

Return Value

VideoTag

Constants

SINGLE_QUOTES

DOUBLE_QUOTES

NAME

IS_VOID