class JavaScriptLazyImage extends Element (View source)

Properties

protected bool $isSelfClosing

Whether the element is self closing.

Methods

__construct($src, $attributes = array(), $lazyLoadNative = false)

No description

create(string|null $src = false, array $attributes = array(), bool|null $lazyLoadNative = false)

Static alias for constructor.

noscriptFallback(string $src, bool $lazyLoadNative = false)

Create an img element wrapped in "". The image will be displayed if JavaScript is disabled.

img(string $src, bool $lazyLoadNative = false)

Create an image element with the image path set to a "data-src" attribute.

alt(string $alt)

Set the image and noscript image fallback "alt" attribute value.

title(string $title)

Set the image and noscript image fallback "title" attribute value.

addClass(string $classes)

Add one or more CSS classes to the image and noscript image fallback.

Details

__construct($src, $attributes = array(), $lazyLoadNative = false)

No description

Parameters

$src
$attributes
$lazyLoadNative

static JavaScriptLazyImage create(string|null $src = false, array $attributes = array(), bool|null $lazyLoadNative = false)

Static alias for constructor.

Parameters

string|null $src
array $attributes
bool|null $lazyLoadNative

Return Value

JavaScriptLazyImage

JavaScriptLazyImage noscriptFallback(string $src, bool $lazyLoadNative = false)

Create an img element wrapped in "". The image will be displayed if JavaScript is disabled.

Example output:

or

Parameters

string $src

The file path of an image.

bool $lazyLoadNative

If true, the image "loading" attribute is set to "lazy".

Return Value

JavaScriptLazyImage

img(string $src, bool $lazyLoadNative = false)

Create an image element with the image path set to a "data-src" attribute.

Example output:

or

Parameters

string $src

The file path of an image.

bool $lazyLoadNative

If true, the image "loading" attribute is set to "lazy".

alt(string $alt)

Set the image and noscript image fallback "alt" attribute value.

Parameters

string $alt

title(string $title)

Set the image and noscript image fallback "title" attribute value.

Parameters

string $title

addClass(string $classes)

Add one or more CSS classes to the image and noscript image fallback.

Parameters

string $classes

A string of space separated CSS classes.