WC_Regenerate_Images::filter_image_get_intermediate_size() public WC 1.0
If an intermediate size meta differs from the actual image size (settings were changed?) return false so the wrong size is not used.
{} Это метод класса: WC_Regenerate_Images{}
Хуки из метода
Возвращает
Массив.
Использование
$result = WC_Regenerate_Images::filter_image_get_intermediate_size( $data, $attachment_id, $size );
- $data(массив) (обязательный)
- Size data.
- $attachment_id(число) (обязательный)
- Attachment ID.
- $size(строка) (обязательный)
- Size name.
Код WC_Regenerate_Images::filter_image_get_intermediate_size() WC Regenerate Images::filter image get intermediate size WC 5.0.0
public static function filter_image_get_intermediate_size( $data, $attachment_id, $size ) {
if ( ! is_string( $size ) || ! in_array( $size, apply_filters( 'woocommerce_image_sizes_to_resize', array( 'woocommerce_thumbnail', 'woocommerce_gallery_thumbnail', 'woocommerce_single', 'shop_thumbnail', 'shop_catalog', 'shop_single' ) ), true ) ) {
return $data;
}
// If we don't have sizes, we cannot proceed.
if ( ! isset( $data['width'], $data['height'] ) ) {
return $data;
}
// See if the image size has changed from our settings.
if ( ! self::image_size_matches_settings( $data, $size ) ) {
// If Photon is running we can just return false and let Jetpack handle regeneration.
if ( method_exists( 'Jetpack', 'is_module_active' ) && Jetpack::is_module_active( 'photon' ) ) {
return false;
} else {
// If we get here, Jetpack is not running and we don't have the correct image sized stored. Try to return closest match.
$size_data = wc_get_image_size( $size );
return image_get_intermediate_size( $attachment_id, array( absint( $size_data['width'] ), absint( $size_data['height'] ) ) );
}
}
return $data;
}