Upload: Set custom header with the attachment ID for all uploads from `media_handle_upload()`. Let the REST API endpoint set it separately.
Props timothyblynjacobs. Fixes #48200. Built from https://develop.svn.wordpress.org/trunk@46421 git-svn-id: http://core.svn.wordpress.org/trunk@46219 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cce502be78
commit
f793398e4f
|
@ -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.
|
// 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.
|
// The js that handles the response would need to also handle HTTP 500 errors.
|
||||||
wp_update_image_subsizes( $attachment_id );
|
wp_update_image_subsizes( $attachment_id );
|
||||||
|
|
|
@ -252,12 +252,6 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
|
||||||
return $image_meta;
|
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
|
// Resize the image
|
||||||
$resized = $editor->resize( $threshold, $threshold );
|
$resized = $editor->resize( $threshold, $threshold );
|
||||||
$rotated = null;
|
$rotated = null;
|
||||||
|
@ -298,10 +292,6 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
|
||||||
return $image_meta;
|
return $image_meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! headers_sent() ) {
|
|
||||||
header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rotate the image
|
// Rotate the image
|
||||||
$rotated = $editor->maybe_exif_rotate();
|
$rotated = $editor->maybe_exif_rotate();
|
||||||
|
|
||||||
|
@ -401,12 +391,6 @@ function _wp_make_subsizes( $new_sizes, $file, $image_meta, $attachment_id ) {
|
||||||
return $image_meta;
|
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 stored EXIF data exists, rotate the source image before creating sub-sizes.
|
||||||
if ( ! empty( $image_meta['image_meta'] ) ) {
|
if ( ! empty( $image_meta['image_meta'] ) ) {
|
||||||
$rotated = $editor->maybe_exif_rotate();
|
$rotated = $editor->maybe_exif_rotate();
|
||||||
|
|
|
@ -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 );
|
$attachment_id = wp_insert_attachment( $attachment, $file, $post_id, true );
|
||||||
|
|
||||||
if ( ! is_wp_error( $attachment_id ) ) {
|
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().
|
// The image sub-sizes are created during wp_generate_attachment_metadata().
|
||||||
// This is generally slow and may cause timeouts or out of memory errors.
|
// 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 ) );
|
wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) );
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue