SrcsetAttribute

final class \TYPO3\CMS\Core\Html\Srcset\SrcsetAttribute

Generates a HTML srcset attribute for responsive images

Table of Contents

Methods

__toString()  : mixed
addCandidate()  : static
createFromDescriptors()  : SrcsetAttribute
generateSrcset()  : string
getCandidates()  : SrcsetCandidate[]

Methods

createFromDescriptors()

public static createFromDescriptors(string[] $descriptors[, int|null $referenceWidth = null ]) : SrcsetAttribute

Parameters

$descriptors : 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

SrcsetAttribute

generateSrcset()

public generateSrcset() : string

Return values

string
On this page