apply_filters( 'wp_img_tag_add_loading_attr', string|bool $value, string $image, string $context )
- Since
- 5.5.0
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.
Compatibility
- WordPress
- since 5.5.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
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.
Where this hook fires · 2
wp-includes/deprecated.php:4799wp_img_tag_add_loading_attr()wp-includes/media.php:2315wp_img_tag_add_loading_optimization_attrs()
Source code
* * @param string|bool $value The `loading` attribute value. Returning a falsey value will result in * the attribute being omitted for the image. * @param string $image The HTML `img` tag to be filtered. * @param string $context Additional context about how the function was called or where the img tag is. */ $filtered_loading_attr = apply_filters( 'wp_img_tag_add_loading_attr', $optimization_attrs['loading'] ?? false, $image, $context );Changelog
Introduced in 5.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
- Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.