Make WordPress Core

Ticket #48111: 48111.2.patch

File 48111.2.patch, 1.0 KB (added by azaozz, 4 years ago)
  • src/wp-admin/includes/image.php

     
    581581
    582582                                // Resize based on the full size image, rather than the source.
    583583                                if ( ! is_wp_error( $uploaded ) ) {
    584                                         $editor = wp_get_image_editor( $uploaded['path'] );
     584                                        $image_file = $uploaded['path'];
    585585                                        unset( $uploaded['path'] );
    586586
    587                                         if ( ! is_wp_error( $editor ) ) {
    588                                                 $metadata['sizes']         = $editor->multi_resize( $merged_sizes );
    589                                                 $metadata['sizes']['full'] = $uploaded;
    590                                         }
     587                                        $metadata['sizes'] = array(
     588                                                'full' => $uploaded,
     589                                        );
     590
     591                                        // Save the meta data before any image post-processing errors could happen.
     592                                        wp_update_attachment_metadata( $attachment_id, $metadata );
     593
     594                                        // Create sub-sizes saving the image meta after each.
     595                                        $metadata = _wp_make_subsizes( $merged_sizes, $image_file, $metadata, $attachment_id );
    591596                                }
    592597                        }
    593598                }