WordPress at Your Fingertips
function is not described

WC_Regenerate_Images::image_size_matches_settings() protected WC 1.0

See if an image's dimensions match actual settings.

{} It's a method of the class: WC_Regenerate_Images{}

No Hooks.

Return

true|false. True if they match. False if they do not (may trigger regen).

Usage

$result = WC_Regenerate_Images::image_size_matches_settings( $image, $size );
$image(array) (required)
Image dimensions array.
$size(string) (required)
Named size.

Code of WC_Regenerate_Images::image_size_matches_settings() WC 5.9.0

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;
}