PictureSourceTag
class PictureSourceTag extends BaseImageTag
Generates an HTML <source>
tag with media
and srcset
attributes that can be used with a <picture>
tag.
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 | |
Image | $image | from BaseImageTag | |
SrcSet | $srcset | from BaseImageTag | |
ImageTransformation | $additionalTransformation | from BaseImageTag |
Methods
Image format of the video poster.
Use fetch format transformation ("f_") instead of file extension.
PictureSourceTag constructor.
Imports (merges) the configuration.
Adds a tag class.
Resets tag classes and sets the specified one.
Sets tag attribute.
Sets (multiple) tag attributes.
Deletes tag attribute.
Adds tag content.
Sets the content of the tag to the specified one.
Serializes the tag to string.
Serializes the tag content.
Serializes the tag attributes.
Serializes the tag to string.
Serializes the tag to string.
Static builder for uploaded asset image tag.
Static builder for fetch image tag (from URL).
Static builder for facebook profile picture tag.
Static builder for gravatar profile picture tag.
Static builder for twitter profile picture tag.
Static builder for twitter profile picture by name.
Static builder for the thumbnail of the YouTube video.
Static builder for the thumbnail of the YouTube video.
Static builder for the thumbnail of the Vimeo video.
Static builder for the thumbnail of the animoto video.
Static builder for the thumbnail of the World Star Hip Hop video.
Static builder for the thumbnail of the DailyMotion video.
Static builder for sprite tag.
Whether to automatically build URLs with multiple CDN sub-domains.
Whether to use secure CDN sub-domain.
The custom domain name to use for building HTTP URLs.
Force HTTPS URLs for resources even if they are embedded in non-secure HTTP pages.
The domain name of the CDN distribution to use for building HTTPS URLs.
Set this parameter to true if you are an Advanced plan user with a private CDN distribution.
Set to true to create a signed Cloudinary URL.
Setting both this and signUrl to true will sign the URL using the first 32 characters of a SHA-256 hash.
Set to true to use shorten asset type.
Set to true to omit type and resource_type in the URL.
Set to false to omit default version string for assets in folders in the delivery URL.
Set to false to omit analytics.
Creates a new base image tag from the provided source and an array of parameters.
Serializes to json.
Adds (appends) a transformation.
Adds (chains) a transformation action.
Explicitly sets the breakpoints.
Defines whether to use auto optimal breakpoints.
Sets the image relative width.
Sets the media query $minWidth and $maxWidth.
Sets the sizes tag attribute.
Details
$this
videoPosterFormat(string $format)
Image format of the video poster.
$this
useFetchFormat(bool $useFetchFormat = true)
Use fetch format transformation ("f_") instead of file extension.
__construct(string|Image $source, int $minWidth = null, int $maxWidth = null, string $sizes = null, Configuration|string|array|null $configuration = null)
PictureSourceTag constructor.
Configuration
configuration(Configuration|string|array|null $configuration)
Sets the configuration.
BaseTag
importConfiguration(Configuration|string|array|null $configuration)
Imports (merges) the configuration.
BaseTag
addClass(string|array $class)
Adds a tag class.
BaseTag
setClass(string|array $class)
Resets tag classes and sets the specified one.
BaseTag
setAttribute(string $key, mixed $value = null)
Sets tag attribute.
BaseTag
setAttributes(array $attributes)
Sets (multiple) tag attributes.
BaseTag
deleteAttribute(string $key)
Deletes tag attribute.
$this
addContent(mixed $content, mixed $key = null)
Adds tag content.
BaseTag
setContent(mixed $content)
Sets the content of the tag to the specified one.
string
serialize()
Serializes the tag to string.
string
serializeContent(array $additionalContent = [], bool $prependAdditionalContent = false)
Serializes the tag content.
string
serializeAttributes(array $attributes = [])
Serializes the tag attributes.
string
toTag()
Serializes the tag to string.
string
__toString()
Serializes the tag to string.
static ImageTagDeliveryTypeTrait
upload(string $publicId, Configuration|string|array|null $configuration = null)
Static builder for uploaded asset image tag.
static ImageTagDeliveryTypeTrait
fetch(string $url, Configuration|string|array|null $configuration = null)
Static builder for fetch image tag (from URL).
static ImageTagDeliveryTypeTrait
facebook(string $facebookId, Configuration|string|array|null $configuration = null)
Static builder for facebook profile picture tag.
static ImageTagDeliveryTypeTrait
gravatar(string $email, Configuration|string|array|null $configuration = null)
Static builder for gravatar profile picture tag.
static ImageTagDeliveryTypeTrait
twitter(string $userId, Configuration|string|array|null $configuration = null)
Static builder for twitter profile picture tag.
static ImageTagDeliveryTypeTrait
twitterName(string $username, Configuration|string|array|null $configuration = null)
Static builder for twitter profile picture by name.
static ImageTagDeliveryTypeTrait
youTube(string $videoId, Configuration|string|array|null $configuration = null)
Static builder for the thumbnail of the YouTube video.
static ImageTagDeliveryTypeTrait
hulu(string $videoId, Configuration|string|array|null $configuration = null)
Static builder for the thumbnail of the YouTube video.
static ImageTagDeliveryTypeTrait
vimeo(string $videoId, Configuration|string|array|null $configuration = null)
Static builder for the thumbnail of the Vimeo video.
static ImageTagDeliveryTypeTrait
animoto(string $videoId, Configuration|string|array|null $configuration = null)
Static builder for the thumbnail of the animoto video.
static ImageTagDeliveryTypeTrait
worldStarHipHop(string $videoId, Configuration|string|array|null $configuration = null)
Static builder for the thumbnail of the World Star Hip Hop video.
static ImageTagDeliveryTypeTrait
dailyMotion(string $videoId, Configuration|string|array|null $configuration = null)
Static builder for the thumbnail of the DailyMotion video.
static ImageTagDeliveryTypeTrait
sprite(string $tag, Configuration|string|array|null $configuration = null)
Static builder for sprite tag.
$this
cdnSubdomain(bool $cdnSubdomain = true)
Whether to automatically build URLs with multiple CDN sub-domains.
$this
secureCdnSubdomain(bool $secureCdnSubdomain = true)
Whether to use secure CDN sub-domain.
$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.
$this
secure(bool $secure = true)
Force HTTPS URLs for resources even if they are embedded in non-secure HTTP pages.
$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.
$this
privateCdn(bool $privateCdn = true)
Set this parameter to true if you are an Advanced plan user with a private CDN distribution.
$this
signUrl(bool $signUrl = true)
Set to true to create a signed Cloudinary URL.
$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.
$this
shorten(bool $shorten = true)
Set to true to use shorten asset type.
$this
useRootPath(bool $useRootPath = true)
Set to true to omit type and resource_type in the URL.
$this
forceVersion(bool $forceVersion = true)
Set to false to omit default version string for assets in folders in the delivery URL.
$this
analytics(bool $analytics = true)
Set to false to omit analytics.
static BaseImageTag
fromParams(string $source, array $params = [])
Creates a new base image tag from the provided source and an array of parameters.
static
handleResponsive(array $params, Configuration $configuration)
BaseImageTag
image(mixed $image, Configuration $configuration = null)
Sets the image.
mixed
jsonSerialize()
Serializes to json.
BaseImageTag
addTransformation(CommonTransformation $transformation)
Adds (appends) a transformation.
Appended transformation is nested.
BaseImageTag
addAction(BaseAction|BaseQualifier|mixed $action)
Adds (chains) a transformation action.
$this
breakpoints(array $breakpoints = null)
Explicitly sets the breakpoints.
$this
autoOptimalBreakpoints(bool $autoOptimalBreakpoints = true)
Defines whether to use auto optimal breakpoints.
$this
relativeWidth(float $relativeWidth = 1.0)
Sets the image relative width.
PictureSourceTag
media(int $minWidth = null, int $maxWidth = null)
Sets the media query $minWidth and $maxWidth.
PictureSourceTag
sizes(string $sizes = null)
Sets the sizes tag attribute.
Constants
SINGLE_QUOTES |
|
DOUBLE_QUOTES |
|
NAME |
|
IS_VOID |
|