Make WordPress Core

Ticket #44867: 0002-44867-handle-new-image-size.patch

File 0002-44867-handle-new-image-size.patch, 1.2 KB (added by drzraf, 6 years ago)

improvement: if cropping as a copy, correctly change corresponding metadata

  • wp-admin/includes/image-edit.php

    From c606a0c9316cc92c1adb4d81001756af21b0fe5b Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Rapha=C3=ABl=20Droz?= <raphael.droz+floss@gmail.com>
    Date: Fri, 4 Jan 2019 10:39:58 -0300
    Subject: [PATCH] #44867 image editor: save modified image as a new copy,
     handle possibly new image size
    
    ---
     wp-admin/includes/image-edit.php | 4 ++++
     1 file changed, 4 insertions(+)
    
    diff --git a/wp-admin/includes/image-edit.php b/wp-admin/includes/image-edit.php
    index 773f3b9..c026876 100644
    a b function wp_save_image( $post_id ) { 
    840840                $sizes = array( 'thumbnail' );
    841841                $success = $delete = $nocrop = true;
    842842        } elseif ( 'new' == $target ) {
     843                $size = $img->get_size();
     844                $meta['width'] = $size['width']; // cropped and saved as a copy
     845                $meta['height'] = $size['height'];
     846
    843847                $new_post = (array)$post;
    844848                unset( $new_post['ID'], $new_post['post_date'], $new_post['post_date_gmt'], $new_post['post_modified'], $new_post['post_modified_gmt'] );
    845849                $new_post['post_title'] = preg_match('/\.[a-z]{3}$/', $new_post['post_title']) ? preg_replace('/(\.[a-z]{3})/', '-media-copy\1', $new_post['post_title']) : $new_post['post_title'] . '-mediacopy';