From 60c2966222e184d0f7548a2c39d828343d023137 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Thu, 7 Nov 2019 18:51:02 +0000 Subject: [PATCH] Upload: When an image was scaled because it is larger than the big image threshold, use the originally uploaded image's dimensions in `wp_get_missing_image_subsizes()`. Fixes an edge case/inconsistent behaviour when a registered image sub-size is also larger than the big image threshold. Props desrosj, azaozz. Fixes #48518 for trunk. Built from https://develop.svn.wordpress.org/trunk@46677 git-svn-id: http://core.svn.wordpress.org/trunk@46477 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/image.php | 16 ++++++++++++++-- wp-includes/version.php | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index 767f754a34..b05c70c15b 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -90,8 +90,20 @@ function wp_get_missing_image_subsizes( $attachment_id ) { return $registered_sizes; } - $full_width = (int) $image_meta['width']; - $full_height = (int) $image_meta['height']; + // Use the originally uploaded image dimensions as full_width and full_height. + if ( ! empty( $image_meta['original_image'] ) ) { + $image_file = wp_get_original_image_path( $attachment_id ); + $imagesize = @getimagesize( $image_file ); + } + + if ( ! empty( $imagesize ) ) { + $full_width = $imagesize[0]; + $full_height = $imagesize[1]; + } else { + $full_width = (int) $image_meta['width']; + $full_height = (int) $image_meta['height']; + } + $possible_sizes = array(); // Skip registered sizes that are too large for the uploaded image. diff --git a/wp-includes/version.php b/wp-includes/version.php index 5d207ee31d..45fe219a13 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.4-alpha-46676'; +$wp_version = '5.4-alpha-46677'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.