WC_Regenerate_Images::image_size_matches_settings()
See if an image's dimensions match actual settings.
Метод класса: WC_Regenerate_Images{}
Хуков нет.
Возвращает
true|false
. True if they match. False if they do not (may trigger regen).
Использование
$result = WC_Regenerate_Images::image_size_matches_settings( $image, $size );
- $image(массив) (обязательный)
- Image dimensions array.
- $size(строка) (обязательный)
- Named size.
Код WC_Regenerate_Images::image_size_matches_settings() WC Regenerate Images::image size matches settings WC 9.2.3
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; }