Filter hook 'wp_omit_loading_attr_threshold'

in WP Core File wp-includes/media.php at line 6213

View Source

wp_omit_loading_attr_threshold

Filter Hook
Description
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.

Hook Information

File Location wp-includes/media.php View on GitHub
Hook Type Filter
Line Number 6213

Hook Parameters

Type Name Description
int $omit_threshold The number of media elements where the `loading` attribute will not be added. Default 3.

Usage Examples

Basic Usage
<?php
// Hook into wp_omit_loading_attr_threshold
add_filter('wp_omit_loading_attr_threshold', 'my_custom_filter', 10, 1);

function my_custom_filter($omit_threshold) {
    // Your custom filtering logic here
    return $omit_threshold;
}

Source Code Context

wp-includes/media.php:6213 - How this hook is used in WordPress core
<?php
6208  		 * @since 5.9.0
6209  		 * @since 6.3.0 The default threshold was changed from 1 to 3.
6210  		 *
6211  		 * @param int $omit_threshold The number of media elements where the `loading` attribute will not be added. Default 3.
6212  		 */
6213  		$omit_threshold = apply_filters( 'wp_omit_loading_attr_threshold', 3 );
6214  	}
6215  
6216  	return $omit_threshold;
6217  }
6218  

PHP Documentation

<?php
/**
		 * 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.
		 *
		 * @since 5.9.0
		 * @since 6.3.0 The default threshold was changed from 1 to 3.
		 *
		 * @param int $omit_threshold The number of media elements where the `loading` attribute will not be added. Default 3.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/media.php
Related Hooks

Related hooks will be displayed here in future updates.