max_srcset_image_width хук-фильтрWP 4.4.0

Filters the maximum image width to be included in a 'srcset' attribute.

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

add_filter( 'max_srcset_image_width', 'wp_kama_max_srcset_image_width_filter', 10, 2 );

/**
 * Function for `max_srcset_image_width` filter-hook.
 * 
 * @param int   $max_width  The maximum image width to be included in the 'srcset'.
 * @param int[] $size_array An array of requested width and height values.
 *
 * @return int
 */
function wp_kama_max_srcset_image_width_filter( $max_width, $size_array ){

	// filter...
	return $max_width;
}
$max_width(int)
The maximum image width to be included in the 'srcset'.
По умолчанию: '2048'
$size_array(int[])

An array of requested width and height values.

  • 0(int)
    The width in pixels.

  • 1(int)
    The height in pixels.

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

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

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

wp_calculate_image_srcset()
max_srcset_image_width
wp-includes/media.php 1390
$max_srcset_image_width = apply_filters( 'max_srcset_image_width', 2048, $size_array );

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

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