Filters the loading attribute value to add to an image. Default lazy.
Description
Returning false or an empty string will not add the attribute.
Returning true will add the default value.
Parameters
$valuestring|bool- The
loadingattribute value. Returning a falsey value will result in the attribute being omitted for the image. $imagestring- The HTML
imgtag to be filtered. $contextstring- Additional context about how the function was called or where the img tag is.
Source
}
/**
* Checks whether the given 'sizes' attribute includes the 'auto' keyword as the first item in the list.
*
* Per the HTML spec, if present it must be the first entry.
Changelog
| Version | Description |
|---|---|
| 5.5.0 | Introduced. |
tl;dr ⨪ this will fix your LCP in pagespeed report for lazy loaded images above the fold
This filter is very useful for images above the fold that don’t need to be lazy loaded (for example logos, featured images etc) so we can hook this filter to read our images and parse for example some custom class that can set lazy loading attribute ON or OFF per image.
– by setting custom class `skip-lazy` inside admin under `Advanced > Additional Classes` inside image settings:
disables it