Make WordPress Core

Changeset 48525


Ignore:
Timestamp:
07/21/2020 02:59:00 AM (4 years ago)
Author:
azaozz
Message:

REST API, Media: Add X-WP-Upload-Attachment-ID HTTP header to enable retrying of post-processing of edited images if the server runs out of resources. This is the same as after uploading a new image, will do up to five additional requests to let the server create all image sub-sizes.

Fixes #50711.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

    r48518 r48525  
    580580            // update_post_meta() expects slashed.
    581581            update_post_meta( $new_attachment_id, '_wp_attachment_image_alt', wp_slash( $image_alt ) );
     582        }
     583
     584        if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
     585            // Set a custom header with the attachment_id.
     586            // Used by the browser/client to resume creating image sub-sizes after a PHP fatal error.
     587            header( 'X-WP-Upload-Attachment-ID: ' . $new_attachment_id );
    582588        }
    583589
Note: See TracChangeset for help on using the changeset viewer.