apply_filters( ‘wp_omit_loading_attr_threshold’, int $omit_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.


The number of media elements where the loading attribute will not be added. Default 3.


$omit_threshold = apply_filters( 'wp_omit_loading_attr_threshold', 3 );


6.3.0The default threshold was changed from 1 to 3.

User Contributed Notes

  1. Skip to note 2 content

    Here’s how you could use the wp_omit_loading_attr_threshold filter to change the threshold back to its original value of 1.

    function wpdocs_change_lazy_loading_threshold( int $omit_threshold ): int {
    	 * In WordPress 6.3.0 the default threshold was changed from 1 to 3.
    	 * This change is to revert the threshold back to 1.
    	return 1;
    add_filter( 'wp_omit_loading_attr_threshold', 'wpdocs_change_lazy_loading_threshold' );

You must log in before being able to contribute a note or feedback.