class PictureTag extends BaseTag

Generates an HTML <picture> tag containing <source> and <img> tags.

For example:

<picture>
<source srcset="https://res.cloudinary.com/demo/image/upload/c_scale,w_500/sample.png" media="(max-width: 500px)">
<source srcset="https://res.cloudinary.com/demo/image/upload/c_scale,w_1000/sample.png" media="(min-width: 500px)">
<img src="https://res.cloudinary.com/demo/image/upload/sample.png">
</picture>

Properties

Configuration $config from BaseTag
ImageTag $imageTag
array $sources

Methods

__construct(string|Image $source, array $sources, Configuration|string|array|null $configuration = null)

PictureTag 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 $publicId, Configuration|string|array|null $configuration = null)

Static builder for uploaded asset image tag.

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

Static builder for fetch image tag (from URL).

facebook(string $facebookId, Configuration|string|array|null $configuration = null)

Static builder for facebook profile picture tag.

gravatar(string $email, Configuration|string|array|null $configuration = null)

Static builder for gravatar profile picture tag.

twitter(string $userId, Configuration|string|array|null $configuration = null)

Static builder for twitter profile picture tag.

twitterName(string $username, Configuration|string|array|null $configuration = null)

Static builder for twitter profile picture by name.

youTube(string $videoId, Configuration|string|array|null $configuration = null)

Static builder for the thumbnail of the YouTube video.

hulu(string $videoId, Configuration|string|array|null $configuration = null)

Static builder for the thumbnail of the YouTube video.

vimeo(string $videoId, Configuration|string|array|null $configuration = null)

Static builder for the thumbnail of the Vimeo video.

animoto(string $videoId, Configuration|string|array|null $configuration = null)

Static builder for the thumbnail of the animoto video.

worldStarHipHop(string $videoId, Configuration|string|array|null $configuration = null)

Static builder for the thumbnail of the World Star Hip Hop video.

dailyMotion(string $videoId, Configuration|string|array|null $configuration = null)

Static builder for the thumbnail of the DailyMotion video.

sprite(string $tag, Configuration|string|array|null $configuration = null)

Static builder for sprite tag.

image(mixed $image)

Sets the image of the picture.

setSources(array $sourcesDefinitions)

Sets the tag sources.

Details

__construct(string|Image $source, array $sources, Configuration|string|array|null $configuration = null)

PictureTag constructor.

Parameters

Name Type Description
$source string|Image The public ID or Image instance.
$sources array The sources definitions.
$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 ImageTagDeliveryTypeTrait upload(string $publicId, Configuration|string|array|null $configuration = null)

Static builder for uploaded asset image tag.

Parameters

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

Return Value

ImageTagDeliveryTypeTrait

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

Static builder for fetch image tag (from URL).

Parameters

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

Return Value

ImageTagDeliveryTypeTrait

static ImageTagDeliveryTypeTrait facebook(string $facebookId, Configuration|string|array|null $configuration = null)

Static builder for facebook profile picture tag.

Parameters

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

Return Value

ImageTagDeliveryTypeTrait

static ImageTagDeliveryTypeTrait gravatar(string $email, Configuration|string|array|null $configuration = null)

Static builder for gravatar profile picture tag.

Parameters

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

Return Value

ImageTagDeliveryTypeTrait

static ImageTagDeliveryTypeTrait twitter(string $userId, Configuration|string|array|null $configuration = null)

Static builder for twitter profile picture tag.

Parameters

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

Return Value

ImageTagDeliveryTypeTrait

static ImageTagDeliveryTypeTrait twitterName(string $username, Configuration|string|array|null $configuration = null)

Static builder for twitter profile picture by name.

Parameters

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

Return Value

ImageTagDeliveryTypeTrait

static ImageTagDeliveryTypeTrait youTube(string $videoId, Configuration|string|array|null $configuration = null)

Static builder for the thumbnail of the YouTube video.

Parameters

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

Return Value

ImageTagDeliveryTypeTrait

static ImageTagDeliveryTypeTrait hulu(string $videoId, Configuration|string|array|null $configuration = null)

Static builder for the thumbnail of the YouTube video.

Parameters

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

Return Value

ImageTagDeliveryTypeTrait

static ImageTagDeliveryTypeTrait vimeo(string $videoId, Configuration|string|array|null $configuration = null)

Static builder for the thumbnail of the Vimeo video.

Parameters

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

Return Value

ImageTagDeliveryTypeTrait

static ImageTagDeliveryTypeTrait animoto(string $videoId, Configuration|string|array|null $configuration = null)

Static builder for the thumbnail of the animoto video.

Parameters

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

Return Value

ImageTagDeliveryTypeTrait

static ImageTagDeliveryTypeTrait worldStarHipHop(string $videoId, Configuration|string|array|null $configuration = null)

Static builder for the thumbnail of the World Star Hip Hop video.

Parameters

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

Return Value

ImageTagDeliveryTypeTrait

static ImageTagDeliveryTypeTrait dailyMotion(string $videoId, Configuration|string|array|null $configuration = null)

Static builder for the thumbnail of the DailyMotion video.

Parameters

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

Return Value

ImageTagDeliveryTypeTrait

static ImageTagDeliveryTypeTrait sprite(string $tag, Configuration|string|array|null $configuration = null)

Static builder for sprite tag.

Parameters

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

Return Value

ImageTagDeliveryTypeTrait

PictureTag image(mixed $image)

Sets the image of the picture.

Parameters

Name Type Description
$image mixed The public ID or Image asset.

Return Value

PictureTag

PictureTag setSources(array $sourcesDefinitions)

Sets the tag sources.

Parameters

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

Return Value

PictureTag

Constants

SINGLE_QUOTES

DOUBLE_QUOTES

NAME

IS_VOID