wp_img_tag_add_loading_attr хук-фильтрWP 5.5.0

Filters the loading attribute value to add to an image. Default lazy.

Returning false or an empty string will not add the attribute. Returning true will add the default value.

Использование

add_filter( 'wp_img_tag_add_loading_attr', 'wp_kama_img_tag_add_loading_attr_filter', 10, 3 );

/**
 * Function for `wp_img_tag_add_loading_attr` filter-hook.
 * 
 * @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.
 *
 * @return string|bool
 */
function wp_kama_img_tag_add_loading_attr_filter( $value, $image, $context ){

	// filter...
	return $value;
}
$value(строка|true|false)
The loading attribute value. Returning a falsey value will result in the attribute being omitted for the image.
$image(строка)
The HTML img tag to be filtered.
$context(строка)
Additional context about how the function was called or where the img tag is.

Список изменений

С версии 5.5.0 Введена.

Где вызывается хук

wp_img_tag_add_loading_optimization_attrs()
wp_img_tag_add_loading_attr
wp_img_tag_add_loading_attr()
wp_img_tag_add_loading_attr
wp-includes/media.php 2046-2051
$filtered_loading_attr = apply_filters(
	'wp_img_tag_add_loading_attr',
	isset( $optimization_attrs['loading'] ) ? $optimization_attrs['loading'] : false,
	$image,
	$context
);
wp-includes/deprecated.php 4799
$value = apply_filters( 'wp_img_tag_add_loading_attr', $value, $image, $context );

Где используется хук в WordPress

Использование не найдено.