WC_Regenerate_Images::filter_image_get_intermediate_size( array $data, int $attachment_id, string $size )
If an intermediate size meta differs from the actual image size (settings were changed?) return false so the wrong size is not used.
Description Description
Parameters Parameters
- $data
-
(Required) Size data.
- $attachment_id
-
(Required) Attachment ID.
- $size
-
(Required) Size name.
Return Return
(array)
Source Source
File: includes/class-wc-regenerate-images.php
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; }