wp_img_tag_add_loading_attr WordPress Filter Hook
The wp_img_tag_add_loading_attr Wordpress hook allows you to add a "loading" attribute to img tags. This can be used to improve the loading time of your website.
apply_filters( 'wp_img_tag_add_loading_attr', string|bool $value , string $image , string $context ) #
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
- $value
(string|bool)The
loadingattribute value. Returning a falsey value will result in the attribute being omitted for the image.- $image
(string)The HTML
imgtag to be filtered.- $context
(string)Additional context about how the function was called or where the img tag is.
Source
File: wp-includes/media.php
Changelog
| Version | Description |
|---|---|
| 5.5.0 | Introduced. |