SrcsetCandidate
AbstractYes
Represents a source candidate for the HTML srcset attribute
Table of Contents
Constants
- DENSITY_UNIT = 'x'
- WIDTH_UNIT = 'w'
Properties
- $uri : string|null
Methods
- __toString() : mixed
- createFromDescriptor() : SrcsetCandidate
- generateSrcset() : string
- getCalculatedWidth() : int
- getDescriptor() : string
- getSanitizedUri() : string|null
- Ensures that the provided URI can be used safely in a srcset attribute
- getUri() : string|null
- setUri() : static
Constants
DENSITY_UNIT
public
mixed
DENSITY_UNIT
= 'x'
WIDTH_UNIT
public
mixed
WIDTH_UNIT
= 'w'
Properties
$uri
protected
string|null
$uri
= null
Methods
__toString()
public
__toString() : mixed
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
SrcsetCandidategenerateSrcset()
public
generateSrcset() : string
Return values
stringgetCalculatedWidth()
public
abstract getCalculatedWidth() : int
Return values
intgetDescriptor()
public
abstract getDescriptor() : string
Return values
stringgetSanitizedUri()
Ensures that the provided URI can be used safely in a srcset attribute
public
getSanitizedUri() : string|null
Return values
string|nullgetUri()
public
getUri() : string|null
Return values
string|nullsetUri()
public
setUri(string $uri) : static
Parameters
- $uri : string