Make WordPress Core

Changeset 31576


Ignore:
Timestamp:
02/27/2015 07:37:47 PM (10 years ago)
Author:
wonderboymusic
Message:

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.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-image-editor-gd.php

    r31040 r31576  
    232232
    233233            $image = $this->_resize( $size_data['width'], $size_data['height'], $size_data['crop'] );
    234 
    235             if( ! is_wp_error( $image ) ) {
     234            $duplicate = ( ( $orig_size['width'] == $size_data['width'] ) && ( $orig_size['height'] == $size_data['height'] ) );
     235
     236            if ( ! is_wp_error( $image ) && ! $duplicate ) {
    236237                $resized = $this->_save( $image );
    237238
  • trunk/src/wp-includes/class-wp-image-editor-imagick.php

    r31127 r31576  
    302302
    303303            $resize_result = $this->resize( $size_data['width'], $size_data['height'], $size_data['crop'] );
    304 
    305             if( ! is_wp_error( $resize_result ) ) {
     304            $duplicate = ( ( $orig_size['width'] == $size_data['width'] ) && ( $orig_size['height'] == $size_data['height'] ) );
     305
     306            if ( ! is_wp_error( $resize_result ) && ! $duplicate ) {
    306307                $resized = $this->_save( $this->image );
    307308
Note: See TracChangeset for help on using the changeset viewer.