From 88ffa41ee33fc621edf3155dad941696a8458989 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sun, 16 Jun 2019 01:33:51 +0000 Subject: [PATCH] Media: Ignore errors coming from `image_resize_dimensions()` when creating sub-sizes (for now). It returns `false` when the requested size is larger than the original image and should be skipped. This triggers new `WP_Error` in `WP_Image_Editor::resize()`. See #40439. Built from https://develop.svn.wordpress.org/trunk@45543 git-svn-id: http://core.svn.wordpress.org/trunk@45354 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/image.php | 10 +++++++++- wp-includes/version.php | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index 03fecac871..951f51fc60 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -235,12 +235,20 @@ function _wp_make_subsizes( $new_sizes, $file, $image_meta, $attachment_id ) { $new_size_meta = $editor->make_subsize( $new_size_data ); if ( is_wp_error( $new_size_meta ) ) { + $error_code = $new_size_meta->get_error_code(); + + if ( $error_code === 'error_getting_dimensions' ) { + // Ignore errors when `image_resize_dimensions()` returns false. + // They mean that the requested size is larger than the original image and should be skipped. + continue; + } + if ( empty( $image_meta['subsize_errors'] ) ) { $image_meta['subsize_errors'] = array(); } $error = array( - 'error_code' => $new_size_meta->get_error_code(), + 'error_code' => $error_code, 'error_message' => $new_size_meta->get_error_message(), ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 4671c658fb..a561c3e8cc 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-45542'; +$wp_version = '5.3-alpha-45543'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.