diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index 773be72833..d1700d9fa0 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -2441,6 +2441,12 @@ function wp_ajax_media_create_image_subsizes() { } } + // Set a custom header with the attachment_id. + // Used by the browser/client to resume creating image sub-sizes after a PHP fatal error. + if ( ! headers_sent() ) { + header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id ); + } + // This can still be pretty slow and cause timeout or out of memory errors. // The js that handles the response would need to also handle HTTP 500 errors. wp_update_image_subsizes( $attachment_id ); diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index f1cf9450c0..1e265d45f7 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -252,12 +252,6 @@ function wp_create_image_subsizes( $file, $attachment_id ) { return $image_meta; } - // Set a custom header with the attachment_id. - // Used by the browser/client to resume creating image sub-sizes after a PHP fatal error. - if ( ! headers_sent() ) { - header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id ); - } - // Resize the image $resized = $editor->resize( $threshold, $threshold ); $rotated = null; @@ -298,10 +292,6 @@ function wp_create_image_subsizes( $file, $attachment_id ) { return $image_meta; } - if ( ! headers_sent() ) { - header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id ); - } - // Rotate the image $rotated = $editor->maybe_exif_rotate(); @@ -401,12 +391,6 @@ function _wp_make_subsizes( $new_sizes, $file, $image_meta, $attachment_id ) { return $image_meta; } - // Set a custom header with the attachment_id. - // Used by the browser/client to resume creating image sub-sizes after a PHP fatal error. - if ( ! headers_sent() ) { - header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id ); - } - // If stored EXIF data exists, rotate the source image before creating sub-sizes. if ( ! empty( $image_meta['image_meta'] ) ) { $rotated = $editor->maybe_exif_rotate(); diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 18e87baa71..b9e9acc99d 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -408,6 +408,12 @@ function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid $attachment_id = wp_insert_attachment( $attachment, $file, $post_id, true ); if ( ! is_wp_error( $attachment_id ) ) { + // Set a custom header with the attachment_id. + // Used by the browser/client to resume creating image sub-sizes after a PHP fatal error. + if ( ! headers_sent() ) { + header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id ); + } + // The image sub-sizes are created during wp_generate_attachment_metadata(). // This is generally slow and may cause timeouts or out of memory errors. wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) ); diff --git a/wp-includes/version.php b/wp-includes/version.php index dab17a50b3..bc690f2b2c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-beta2-46420'; +$wp_version = '5.3-beta2-46421'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.