MobileFrontend
Mobile optimised frontend for MediaWiki
Loading...
Searching...
No Matches
MobileFrontend\Transforms\LazyImageTransform Class Reference
+ Inheritance diagram for MobileFrontend\Transforms\LazyImageTransform:
+ Collaboration diagram for MobileFrontend\Transforms\LazyImageTransform:

Public Member Functions

 __construct ( $skipSmallImages=false)
 
 apply (DOMElement $node)
 Insert a table of content placeholder into the element which will be progressively enhanced via JS.
 
 getImageDimensions (DOMElement $img)
 Determine the user perceived width and height of an image element based on style, width, and height attributes.
 
 isDimensionSmallerThanThreshold ( $dimension)
 Is image dimension small enough to not lazy load it.
 

Static Public Member Functions

static gradeCImageSupport ()
 Fallback for Grade C to load lazy-load image placeholders.
 

Protected Attributes

 $skipSmall
 

Constructor & Destructor Documentation

◆ __construct()

MobileFrontend\Transforms\LazyImageTransform::__construct ( $skipSmallImages = false)
Parameters
bool$skipSmallImageswhether small images should be excluded from lazy loading

Member Function Documentation

◆ apply()

MobileFrontend\Transforms\LazyImageTransform::apply ( DOMElement $node)

Insert a table of content placeholder into the element which will be progressively enhanced via JS.

Parameters
DOMElement$nodeto be transformed

Implements MobileFrontend\Transforms\IMobileTransform.

◆ getImageDimensions()

MobileFrontend\Transforms\LazyImageTransform::getImageDimensions ( DOMElement $img)

Determine the user perceived width and height of an image element based on style, width, and height attributes.

As in the browser, the style attribute takes precedence over the width and height attributes. If the image has no style, width or height attributes, then the image is dimensionless.

Parameters
DOMElement$imgelement
Returns
array with width and height parameters if dimensions are found

◆ gradeCImageSupport()

static MobileFrontend\Transforms\LazyImageTransform::gradeCImageSupport ( )
static

Fallback for Grade C to load lazy-load image placeholders.

Note: This will add a single repaint for Grade C browsers as images enter view but this is intentional and deemed acceptable.

Returns
string The JavaScript code to load lazy placeholders in Grade C browsers

◆ isDimensionSmallerThanThreshold()

MobileFrontend\Transforms\LazyImageTransform::isDimensionSmallerThanThreshold ( $dimension)

Is image dimension small enough to not lazy load it.

Parameters
string$dimensionin css format, supports only px|ex units
Returns
bool

The documentation for this class was generated from the following file: