SrcsetAttribute
FinalYes
Generates a HTML srcset attribute for responsive images
Table of Contents
Methods
- __toString() : mixed
- addCandidate() : static
- createFromDescriptors() : SrcsetAttribute
- generateSrcset() : string
- getCandidates() : array<string|int, SrcsetCandidate>
Methods
__toString()
public
__toString() : mixed
addCandidate()
public
addCandidate(SrcsetCandidate $candidate) : static
Parameters
- $candidate : SrcsetCandidate
Return values
staticcreateFromDescriptors()
public
static createFromDescriptors(array<string|int, string> $descriptors[, int|null $referenceWidth = null ]) : SrcsetAttribute
Parameters
- $descriptors : array<string|int, string>
-
Array of srcset width (like "300w, 500w") or density (like "1x, 2x") descriptors.
- $referenceWidth : int|null = null
-
Needs to be provided if $descriptors contains density descriptors (like "2x") to be able to resolve the relative image dimensions. The absolute $referenceWidth will be used as "1x" width.
Return values
SrcsetAttributegenerateSrcset()
public
generateSrcset() : string
Return values
stringgetCandidates()
public
getCandidates() : array<string|int, SrcsetCandidate>