Add caching to get image size

This commit is contained in:
Mike Jolley 2019-02-21 16:58:28 +00:00
parent 271c48e3af
commit 287d65ab65
1 changed files with 8 additions and 1 deletions

View File

@ -203,7 +203,14 @@ class WC_Regenerate_Images {
return $image;
}
// Get image size - use cache if set.
$image_size = wp_cache_get( 'size-' . $size, 'regenerate-images' );
if ( ! $image_size ) {
$image_size = wc_get_image_size( $size );
wp_cache_set( 'size-' . $size, $image_size, 'regenerate-images' );
}
$ratio_match = false;
// If '' is passed to either size, we test ratios against the original file. It's uncropped.