wp_omit_loading_attr_threshold( bool $force = false ): int

In this article

Gets the threshold for how many of the first content media elements to not lazy-load.

Description

This function runs the ‘wp_omit_loading_attr_threshold’ filter, which uses a default threshold value of 3.
The filter is only run once per page load, unless the $force parameter is used.

Parameters

$forcebooloptional
If set to true, the filter will be (re-)applied even if it already has been before.

Default:false

Return

int The number of content media elements to not lazy-load.

Source

 * @global WP_Query $wp_query WordPress Query object.
 *
 * @param string $tag_name The tag name.
 * @param array  $attr     Array of the attributes for the tag.
 * @param string $context  Context for the element for which the loading optimization attribute is requested.
 * @return array Loading optimization attributes.
 */
function wp_get_loading_optimization_attributes( $tag_name, $attr, $context ) {
	global $wp_query;

	/**
	 * Filters whether to short-circuit loading optimization attributes.
	 *
	 * Returning an array from the filter will effectively short-circuit the loading of optimization attributes,
	 * returning that value instead.
	 *
	 * @since 6.4.0
	 *
	 * @param array|false $loading_attrs False by default, or array of loading optimization attributes to short-circuit.
	 * @param string      $tag_name      The tag name.
	 * @param array       $attr          Array of the attributes for the tag.

Changelog

VersionDescription
5.9.0Introduced.

User Contributed Notes

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