WordPress.org

Make WordPress Core

Ticket #48200: 48200.2.diff

File 48200.2.diff, 3.1 KB (added by TimothyBlynJacobs, 6 weeks ago)
  • src/wp-admin/includes/ajax-actions.php

    diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php
    index 773be72833..d1700d9fa0 100644
    a b function wp_ajax_media_create_image_subsizes() { 
    24412441                }
    24422442        }
    24432443
     2444        // Set a custom header with the attachment_id.
     2445        // Used by the browser/client to resume creating image sub-sizes after a PHP fatal error.
     2446        if ( ! headers_sent() ) {
     2447                header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id );
     2448        }
     2449
    24442450        // This can still be pretty slow and cause timeout or out of memory errors.
    24452451        // The js that handles the response would need to also handle HTTP 500 errors.
    24462452        wp_update_image_subsizes( $attachment_id );
  • src/wp-admin/includes/image.php

    diff --git a/src/wp-admin/includes/image.php b/src/wp-admin/includes/image.php
    index 1582ceb3df..31577acc25 100644
    a b function wp_create_image_subsizes( $file, $attachment_id ) { 
    251251                        return $image_meta;
    252252                }
    253253
    254                 // Set a custom header with the attachment_id.
    255                 // Used by the browser/client to resume creating image sub-sizes after a PHP fatal error.
    256                 if ( ! headers_sent() ) {
    257                         header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id );
    258                 }
    259 
    260254                // Resize the image
    261255                $resized = $editor->resize( $threshold, $threshold );
    262256                $rotated = null;
    function wp_create_image_subsizes( $file, $attachment_id ) { 
    297291                        return $image_meta;
    298292                }
    299293
    300                 if ( ! headers_sent() ) {
    301                         header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id );
    302                 }
    303 
    304294                // Rotate the image
    305295                $rotated = $editor->maybe_exif_rotate();
    306296
    function _wp_make_subsizes( $new_sizes, $file, $image_meta, $attachment_id ) { 
    400390                return $image_meta;
    401391        }
    402392
    403         // Set a custom header with the attachment_id.
    404         // Used by the browser/client to resume creating image sub-sizes after a PHP fatal error.
    405         if ( ! headers_sent() ) {
    406                 header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id );
    407         }
    408 
    409393        // If stored EXIF data exists, rotate the source image before creating sub-sizes.
    410394        if ( ! empty( $image_meta['image_meta'] ) ) {
    411395                $rotated = $editor->maybe_exif_rotate();
  • src/wp-admin/includes/media.php

    diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php
    index 18e87baa71..b9e9acc99d 100644
    a b function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid 
    408408        $attachment_id = wp_insert_attachment( $attachment, $file, $post_id, true );
    409409
    410410        if ( ! is_wp_error( $attachment_id ) ) {
     411                // Set a custom header with the attachment_id.
     412                // Used by the browser/client to resume creating image sub-sizes after a PHP fatal error.
     413                if ( ! headers_sent() ) {
     414                        header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id );
     415                }
     416
    411417                // The image sub-sizes are created during wp_generate_attachment_metadata().
    412418                // This is generally slow and may cause timeouts or out of memory errors.
    413419                wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) );