From 5eba5381e6305f06ba4aa17256d47b26ae11be7d Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Tue, 16 Jul 2019 21:48:56 +0000 Subject: [PATCH] Media: Sort the new sizes array by priority when creating image sub-sizes. See #40439. Built from https://develop.svn.wordpress.org/trunk@45645 git-svn-id: http://core.svn.wordpress.org/trunk@45456 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/image.php | 12 ++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index 374bde41c8..9328b1d7d3 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -227,6 +227,18 @@ function _wp_make_subsizes( $new_sizes, $file, $image_meta, $attachment_id ) { } if ( ! empty( $new_sizes ) ) { + // Sort the image sub-sizes in order of priority when creating them. + // This ensures there is an appropriate sub-size the user can access immediately + // even when there was an error and not all sub-sizes were created. + $priority = array( + 'medium' => null, + 'large' => null, + 'thumbnail' => null, + 'medium_large' => null, + ); + + $new_sizes = array_filter( array_merge( $priority, $new_sizes ) ); + $editor = wp_get_image_editor( $file ); if ( ! is_wp_error( $editor ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 8b8dca3371..b35ec97bd0 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-45644'; +$wp_version = '5.3-alpha-45645'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.