DensitySrcsetCandidate

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

Extends
SrcsetCandidate

Represents a source candidate for the HTML srcset attribute using the "x" unit (relative pixel density, like "1x" or "2x")

Table of Contents

Constants

DENSITY_UNIT  : mixed = 'x'
WIDTH_UNIT  : mixed = 'w'

Properties

$density  : float
$referenceWidth  : int|null
$uri  : string|null

Methods

__construct()  : mixed
__toString()  : mixed
createFromDescriptor()  : SrcsetCandidate
generateSrcset()  : string
getCalculatedWidth()  : int
getDensity()  : float
getDescriptor()  : string
getReferenceWidth()  : int|null
getSanitizedUri()  : string|null
Ensures that the provided URI can be used safely in a srcset attribute
getUri()  : string|null
setDensity()  : static
setReferenceWidth()  : static
The absolute $referenceWidth will be used as "1x" width.
setUri()  : static

Constants

DENSITY_UNIT

public mixed DENSITY_UNIT = 'x'

Properties

$referenceWidth

protected int|null $referenceWidth = null

Methods

__construct()

public __construct(float $density[, int|null $referenceWidth = null ]) : mixed

Parameters

$density : float
$referenceWidth : int|null = null

createFromDescriptor()

public static createFromDescriptor(string $descriptor[, int|null $referenceWidth = null ]) : SrcsetCandidate

Parameters

$descriptor : string

srcset width (like "300w") or density (like "2x") descriptor.

$referenceWidth : int|null = null

Needs to be provided if $descriptor is a density descriptor (like "2x") to be able to resolve the relative image dimensions. The absolute $referenceWidth will be used as "1x" width.

Return values

SrcsetCandidate

generateSrcset()

public generateSrcset() : string

Return values

string

getCalculatedWidth()

public getCalculatedWidth() : int

Return values

int

getDensity()

public getDensity() : float

Return values

float

getDescriptor()

public getDescriptor() : string

Return values

string

getReferenceWidth()

public getReferenceWidth() : int|null

Return values

int|null

getSanitizedUri()

Ensures that the provided URI can be used safely in a srcset attribute

public getSanitizedUri() : string|null

Return values

string|null

getUri()

public getUri() : string|null

Return values

string|null

setDensity()

public setDensity(float $density) : static

Parameters

$density : float

Return values

static

setReferenceWidth()

The absolute $referenceWidth will be used as "1x" width.

public setReferenceWidth(int $referenceWidth) : static

Parameters

$referenceWidth : int

Return values

static

setUri()

public setUri(string $uri) : static

Parameters

$uri : string

Return values

static
On this page