wp_omit_loading_attr_threshold
Filters the threshold for how many of the first content media elements to not lazy-load.
For these first content media elements, the loading attribute will be omitted. By default, this is the case for only the very first content media element.
Usage
add_filter( 'wp_omit_loading_attr_threshold', 'wp_kama_omit_loading_attr_threshold_filter' );
/**
* Function for `wp_omit_loading_attr_threshold` filter-hook.
*
* @param int $omit_threshold The number of media elements where the `loading` attribute will not be added.
*
* @return int
*/
function wp_kama_omit_loading_attr_threshold_filter( $omit_threshold ){
// filter...
return $omit_threshold;
}
- $omit_threshold(int)
- The number of media elements where the
loadingattribute will not be added.
Default: 3
Changelog
| Since 5.9.0 | Introduced. |
| Since 6.3.0 | The default threshold was changed from 1 to 3. |
Where the hook is called
wp_omit_loading_attr_threshold
wp-includes/media.php 6255
$omit_threshold = apply_filters( 'wp_omit_loading_attr_threshold', 3 );