class VideoSourceTag extends BaseTag

Generates an HTML <source> tag that can be used with a <video> tag.

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
Video $video
VideoTransformation $additionalTransformation

Methods

videoPosterFormat(string $format)

Image format of the video poster.

useFetchFormat(bool $useFetchFormat = true)

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

__construct(mixed $asset, Configuration|string|array|null $configuration = null, null $additionalTransformation = null)

VideoSourceTag 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.

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

Sets the video of the tag.

type(SourceType|string $type, string|array $codecs = null)

Sets the type.

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(mixed $asset, Configuration|string|array|null $configuration = null, null $additionalTransformation = null)

VideoSourceTag constructor.

Parameters

Name Type Description
$asset mixed The public ID or the Video asset.
$configuration Configuration|string|array|null The Configuration source.
$additionalTransformation null Additional transformation to be applied.

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

VideoSourceTag 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

VideoSourceTag

VideoSourceTag type(SourceType|string $type, string|array $codecs = null)

Sets the type.

Parameters

Name Type Description
$type SourceType|string The type of the source.
$codecs string|array The codecs.

Return Value

VideoSourceTag

Constants

SINGLE_QUOTES

DOUBLE_QUOTES

NAME

IS_VOID