intermediate_image_sizes_advanced хук-фильтрWP 2.9.0

Filters the image sizes automatically generated when uploading an image.

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

add_filter( 'intermediate_image_sizes_advanced', 'wp_kama_intermediate_image_sizes_advanced_filter', 10, 3 );

/**
 * Function for `intermediate_image_sizes_advanced` filter-hook.
 * 
 * @param array $new_sizes     Associative array of image sizes to be created.
 * @param array $image_meta    The image meta data: width, height, file, sizes, etc.
 * @param int   $attachment_id The attachment post ID for the image.
 *
 * @return array
 */
function wp_kama_intermediate_image_sizes_advanced_filter( $new_sizes, $image_meta, $attachment_id ){

	// filter...
	return $new_sizes;
}
$new_sizes(массив)
Associative array of image sizes to be created.
$image_meta(массив)
The image meta data: width, height, file, sizes, etc.
$attachment_id(int)
The attachment post ID for the image.

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

С версии 2.9.0 Введена.
С версии 4.4.0 Added the $image_meta argument.
С версии 5.3.0 Added the $attachment_id argument.

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

wp_create_image_subsizes()
intermediate_image_sizes_advanced
wp-admin/includes/image.php 375
$new_sizes = apply_filters( 'intermediate_image_sizes_advanced', $new_sizes, $image_meta, $attachment_id );

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

wp-admin/includes/ajax-actions.php 3988
add_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) );
wp-admin/includes/ajax-actions.php 3990
remove_filter( 'intermediate_image_sizes_advanced', array( $wp_site_icon, 'additional_sizes' ) );