From dbc38ea246d672ed4d70a61b7866f86b79137ff6 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 27 Feb 2015 19:38:27 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@31576 git-svn-id: http://core.svn.wordpress.org/trunk@31557 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-image-editor-gd.php | 3 ++- wp-includes/class-wp-image-editor-imagick.php | 3 ++- wp-includes/version.php | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-wp-image-editor-gd.php b/wp-includes/class-wp-image-editor-gd.php index 37598b2a5e..371552c28c 100644 --- a/wp-includes/class-wp-image-editor-gd.php +++ b/wp-includes/class-wp-image-editor-gd.php @@ -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 ); diff --git a/wp-includes/class-wp-image-editor-imagick.php b/wp-includes/class-wp-image-editor-imagick.php index 5dc326f021..a70bebdaeb 100644 --- a/wp-includes/class-wp-image-editor-imagick.php +++ b/wp-includes/class-wp-image-editor-imagick.php @@ -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(); diff --git a/wp-includes/version.php b/wp-includes/version.php index 287a5b0d66..81b95148f6 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-alpha-31575'; +$wp_version = '4.2-alpha-31576'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.