In the `->multi_resize()` method of the `WP_Image_Editor` subclasses, when looping through potential crops, we need to make sure the crop isn't the exact same dimensions as the original image before copying it as a new crop.

This ensures that we don't save multiple copies of the same image.

Supposedly broke in [30639], but this logic was always missing. When I tested reverting [30639], there were still 2 files being created.

Fixes #31296.


git-svn-id: https://develop.svn.wordpress.org/trunk@31576 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2015-02-27 19:37:47 +00:00
parent 212d6d8046
commit fed3b8fd1f
2 changed files with 4 additions and 2 deletions

View File

@ -231,8 +231,9 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
}
$image = $this->_resize( $size_data['width'], $size_data['height'], $size_data['crop'] );
$duplicate = ( ( $orig_size['width'] == $size_data['width'] ) && ( $orig_size['height'] == $size_data['height'] ) );
if( ! is_wp_error( $image ) ) {
if ( ! is_wp_error( $image ) && ! $duplicate ) {
$resized = $this->_save( $image );
imagedestroy( $image );

View File

@ -301,8 +301,9 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
}
$resize_result = $this->resize( $size_data['width'], $size_data['height'], $size_data['crop'] );
$duplicate = ( ( $orig_size['width'] == $size_data['width'] ) && ( $orig_size['height'] == $size_data['height'] ) );
if( ! is_wp_error( $resize_result ) ) {
if ( ! is_wp_error( $resize_result ) && ! $duplicate ) {
$resized = $this->_save( $this->image );
$this->image->clear();