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/wp-admin/includes/image-edit.php
+++ b/wp-admin/includes/image-edit.php
@@ -840,6 +840,10 @@ function wp_save_image( $post_id ) {
 		$sizes = array( 'thumbnail' );
 		$success = $delete = $nocrop = true;
 	} elseif ( 'new' == $target ) {
+		$size = $img->get_size();
+		$meta['width'] = $size['width']; // cropped and saved as a copy
+		$meta['height'] = $size['height'];
+
 		$new_post = (array)$post;
 		unset( $new_post['ID'], $new_post['post_date'], $new_post['post_date_gmt'], $new_post['post_modified'], $new_post['post_modified_gmt'] );
 		$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';
-- 
2.17.1

