WC_Regenerate_Images::image_size_matches_settings( array $image, string $size )
See if an image’s dimensions match actual settings.
Description Description
Parameters Parameters
- $image
-
(Required) Image dimensions array.
- $size
-
(Required) Named size.
Return Return
(bool) True if they match. False if they do not (may trigger regen).
Source Source
File: includes/class-wc-regenerate-images.php
protected static function image_size_matches_settings( $image, $size ) { $target_size = wc_get_image_size( $size ); $uncropped = '' === $target_size['width'] || '' === $target_size['height']; if ( ! $uncropped ) { $ratio_match = wp_image_matches_ratio( $image['width'], $image['height'], $target_size['width'], $target_size['height'] ); // Size is invalid if the widths or crop setting don't match. if ( $ratio_match && $target_size['width'] !== $image['width'] ) { return false; } // Size is invalid if the heights don't match. if ( $ratio_match && $target_size['height'] && $target_size['height'] !== $image['height'] ) { return false; } } // If cropping mode has changed, regenerate the image. if ( $uncropped && empty( $image['uncropped'] ) ) { return false; } return true; }