From 66c8085fc4ed1ade989e949d8b7959af903d6cf1 Mon Sep 17 00:00:00 2001 From: Mike Schroder Date: Fri, 11 Oct 2019 07:54:03 +0000 Subject: [PATCH] Media: Update fallback previews to support `_wp_make_subsizes()` Allows fallback previews (PDF by default, in core) to save image meta after each size is generated to allow for resuming, and make sizes immediately available. Props azaozz, antpb, progremzion, mikeschroder. See #48111. Built from https://develop.svn.wordpress.org/trunk@46459 git-svn-id: http://core.svn.wordpress.org/trunk@46257 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/image.php | 15 ++++++++++----- wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index 1e265d45f7..41efa0ad13 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -581,13 +581,18 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) { // Resize based on the full size image, rather than the source. if ( ! is_wp_error( $uploaded ) ) { - $editor = wp_get_image_editor( $uploaded['path'] ); + $image_file = $uploaded['path']; unset( $uploaded['path'] ); - if ( ! is_wp_error( $editor ) ) { - $metadata['sizes'] = $editor->multi_resize( $merged_sizes ); - $metadata['sizes']['full'] = $uploaded; - } + $metadata['sizes'] = array( + 'full' => $uploaded, + ); + + // Save the meta data before any image post-processing errors could happen. + wp_update_attachment_metadata( $attachment_id, $metadata ); + + // Create sub-sizes saving the image meta after each. + $metadata = _wp_make_subsizes( $merged_sizes, $image_file, $metadata, $attachment_id ); } } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 84a78d8d7b..3a7610c322 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-beta3-46458'; +$wp_version = '5.3-beta3-46459'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.