@@ -202,17 +202,21 @@ public function create_item( $request ) {
202
202
wp_after_insert_post ( $ attachment , false , null );
203
203
204
204
if ( defined ( 'REST_REQUEST ' ) && REST_REQUEST ) {
205
- // Set a custom header with the attachment_id.
206
- // Used by the browser/client to resume creating image sub-sizes after a PHP fatal error.
205
+ /*
206
+ * Set a custom header with the attachment_id.
207
+ * Used by the browser/client to resume creating image sub-sizes after a PHP fatal error.
208
+ */
207
209
header ( 'X-WP-Upload-Attachment-ID: ' . $ attachment_id );
208
210
}
209
211
210
212
// Include media and image functions to get access to wp_generate_attachment_metadata().
211
213
require_once ABSPATH . 'wp-admin/includes/media.php ' ;
212
214
require_once ABSPATH . 'wp-admin/includes/image.php ' ;
213
215
214
- // Post-process the upload (create image sub-sizes, make PDF thumbnails, etc.) and insert attachment meta.
215
- // At this point the server may run out of resources and post-processing of uploaded images may fail.
216
+ /*
217
+ * Post-process the upload (create image sub-sizes, make PDF thumbnails, etc.) and insert attachment meta.
218
+ * At this point the server may run out of resources and post-processing of uploaded images may fail.
219
+ */
216
220
wp_update_attachment_metadata ( $ attachment_id , wp_generate_attachment_metadata ( $ attachment_id , $ file ) );
217
221
218
222
$ response = $ this ->prepare_item_for_response ( $ attachment , $ request );
@@ -562,8 +566,10 @@ public function edit_media_item( $request ) {
562
566
$ image_ext = pathinfo ( $ image_file , PATHINFO_EXTENSION );
563
567
$ image_name = wp_basename ( $ image_file , ". {$ image_ext }" );
564
568
565
- // Do not append multiple `-edited` to the file name.
566
- // The user may be editing a previously edited image.
569
+ /*
570
+ * Do not append multiple `-edited` to the file name.
571
+ * The user may be editing a previously edited image.
572
+ */
567
573
if ( preg_match ( '/-edited(-\d+)?$/ ' , $ image_name ) ) {
568
574
// Remove any `-1`, `-2`, etc. `wp_unique_filename()` will add the proper number.
569
575
$ image_name = preg_replace ( '/-edited(-\d+)?$/ ' , '-edited ' , $ image_name );
@@ -625,8 +631,10 @@ public function edit_media_item( $request ) {
625
631
}
626
632
627
633
if ( defined ( 'REST_REQUEST ' ) && REST_REQUEST ) {
628
- // Set a custom header with the attachment_id.
629
- // Used by the browser/client to resume creating image sub-sizes after a PHP fatal error.
634
+ /*
635
+ * Set a custom header with the attachment_id.
636
+ * Used by the browser/client to resume creating image sub-sizes after a PHP fatal error.
637
+ */
630
638
header ( 'X-WP-Upload-Attachment-ID: ' . $ new_attachment_id );
631
639
}
632
640
0 commit comments