From fbf90e465b8a640f369ca46d632711ff465015bd Mon Sep 17 00:00:00 2001 From: danielbachhuber Date: Tue, 7 Feb 2023 17:24:15 +0000 Subject: [PATCH] Media: Bail early if image is already the requested size. In `WP_Image_Editor_Imagick`, bail early in `make_subsize()` if the image is already the requested size. Previously, `make_subsize()` would create another copy of the file. `WP_Image_Editor_GD` doesn't have the same problem. Props wojtekn, danielbachhuber. Fixes #57370. Built from https://develop.svn.wordpress.org/trunk@55278 git-svn-id: http://core.svn.wordpress.org/trunk@54811 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-image-editor-imagick.php | 4 ++++ wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wp-includes/class-wp-image-editor-imagick.php b/wp-includes/class-wp-image-editor-imagick.php index f413387233..ee12b401d9 100644 --- a/wp-includes/class-wp-image-editor-imagick.php +++ b/wp-includes/class-wp-image-editor-imagick.php @@ -503,6 +503,10 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { $size_data['crop'] = false; } + if ( ( $this->size['width'] == $size_data['width'] ) && ( $this->size['height'] == $size_data['height'] ) ) { + return new WP_Error( 'image_subsize_create_error', __( 'The image already has the requested size.' ) ); + } + $resized = $this->resize( $size_data['width'], $size_data['height'], $size_data['crop'] ); if ( is_wp_error( $resized ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 61c5672171..27efe79cec 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-alpha-55277'; +$wp_version = '6.2-alpha-55278'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.