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'

Properties

Methods

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 abstract getCalculatedWidth() : int
Return values
int

getDescriptor()

public abstract getDescriptor() : string
Return values
string

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

setUri()

public setUri(string $uri) : static
Parameters
$uri : string
Return values
static

        
On this page

Search results