big_image_size_threshold хук-фильтрWP 5.3.0

Filters the "BIG image" threshold value.

If the original image width or height is above the threshold, it will be scaled down. The threshold is used as max width and max height. The scaled down image will be used as the largest available size, including the _wp_attached_file post meta value.

Returning false from the filter callback will disable the scaling.

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

add_filter( 'big_image_size_threshold', 'wp_kama_big_image_size_threshold_filter', 10, 4 );

/**
 * Function for `big_image_size_threshold` filter-hook.
 * 
 * @param int    $threshold     The threshold value in pixels.
 * @param array  $imagesize     Indexed array of the image width and height in pixels.
 * @param string $file          Full path to the uploaded image file.
 * @param int    $attachment_id Attachment post ID.
 *
 * @return int
 */
function wp_kama_big_image_size_threshold_filter( $threshold, $imagesize, $file, $attachment_id ){

	// filter...
	return $threshold;
}
$threshold(int)
The threshold value in pixels.
По умолчанию: 2560
$imagesize(массив)

Indexed array of the image width and height in pixels.

  • 0(int)
    The image width.

  • 1(int)
    The image height.
$file(строка)
Full path to the uploaded image file.
$attachment_id(int)
Attachment post ID.

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

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

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

wp_create_image_subsizes()
big_image_size_threshold
wp-admin/includes/image.php 288
$threshold = (int) apply_filters( 'big_image_size_threshold', 2560, $imagesize, $file, $attachment_id );

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

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