WC_Regenerate_Images::filter_image_get_intermediate_size()
If an intermediate size meta differs from the actual image size (settings were changed?) return false so the wrong size is not used.
Method of the class: WC_Regenerate_Images{}
Hooks from the method
Return
Array
.
Usage
$result = WC_Regenerate_Images::filter_image_get_intermediate_size( $data, $attachment_id, $size );
- $data(array) (required)
- Size data.
- $attachment_id(int) (required)
- Attachment ID.
- $size(string) (required)
- Size name.
WC_Regenerate_Images::filter_image_get_intermediate_size() WC Regenerate Images::filter image get intermediate size code WC 9.6.1
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' ) ), 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; }