WordPress.org

Make WordPress Core

Ticket #32171: 32171.diff

File 32171.diff, 956 bytes (added by bradt, 5 years ago)
  • src/wp-admin/includes/image-edit.php

    diff --git src/wp-admin/includes/image-edit.php src/wp-admin/includes/image-edit.php
    index 4015f30..a00fba1 100644
    function wp_save_image( $post_id ) { 
    797797                $success = $delete = $nocrop = true;
    798798        }
    799799
     800        /*
     801         * We need to remove any existing resized image files because
     802         * a new crop could generate different image file sizes and so
     803         * different file names, and so the new resized images won't
     804         * necessarily overwrite the existing resized image files
     805         * https://core.trac.wordpress.org/ticket/32171
     806        */
     807        if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) {
     808                foreach ( $meta['sizes'] as $size ) {
     809                        if ( preg_match('/-e[0-9]{13}-/', $size['file'] ) ) {
     810                                $delete_file = path_join( dirname( $new_path ), $size['file'] );
     811                                wp_delete_file( $delete_file );
     812                        }
     813                }
     814        }
     815
    800816        if ( isset( $sizes ) ) {
    801817                $_sizes = array();
    802818