Media: Sort the new sizes array by priority when creating image sub-sizes.

See #40439.

git-svn-id: https://develop.svn.wordpress.org/trunk@45645 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2019-07-16 21:47:35 +00:00
parent 98a2971872
commit 9d00289c60

View File

@ -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 ) ) {