Skip to content

Commit

Permalink
Fix typo in the apiFetch() path. Add the 'X-WP-Upload-Attachment-ID' …
Browse files Browse the repository at this point in the history
…HTTP header as back-compat to retry failed post-processing of edited images. (#24081)
  • Loading branch information
azaozz authored and youknowriad committed Aug 10, 2020
1 parent cb21f80 commit 9eb9616
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/class-wp-rest-image-editor-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,12 @@ public function apply_edits( $request ) {
return $new_attachment_id;
}

if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
// Set a custom header with the attachment_id.
// Used by the browser/client to resume creating image sub-sizes after a PHP fatal error.
header( 'X-WP-Upload-Attachment-ID: ' . $new_attachment_id );
}

// Generate image sub-sizes and meta.
$new_image_meta = wp_generate_attachment_metadata( $new_attachment_id, $saved['path'] );

Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/image/image-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export default function ImageEditor( {
attrs.src = url;

apiFetch( {
path: `wp/v2/media/${ id }/edit`,
path: `/wp/v2/media/${ id }/edit`,
method: 'POST',
data: attrs,
} )
Expand Down

0 comments on commit 9eb9616

Please sign in to comment.