Make WordPress Core

Changeset 53848


Ignore:
Timestamp:
08/05/2022 10:14:09 PM (4 years ago)
Author:
adamsilverstein
Message:

Media: use original image size data for full size secondary mime generation.

Correct an issue where the secondary mime type full size image would not be properly resized (and -scaled added to the name) when the original upload is over the big_image_size_threshold dimensions.

Props mukesh27.
See #55443.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/image.php

    r53847 r53848  
    342342
    343343        if ( ! empty( $additional_mime_types ) ) {
    344                 // Use the original file's exif_meta orientation information for secondary mime generation.
    345                 $saved_orientation                       = $image_meta['image_meta']['orientation'];
     344                // Use the original file's exif_meta orientation and size information for secondary mime generation to ensure
     345                // sub-sized images are correctly scaled and rotated.
     346
     347                // Save data.
     348                $saved_meta                = array();
     349                $saved_meta['orientation'] = $image_meta['image_meta']['orientation'];
     350                $saved_meta['width']       = $image_meta['width'];
     351                $saved_meta['height']      = $image_meta['height'];
     352
     353                // Temporarily set the image meta to the original file's meta.
    346354                $image_meta['image_meta']['orientation'] = $exif_meta['orientation'];
    347                 $image_meta                              = _wp_make_additional_mime_types( $additional_mime_types, $file, $image_meta, $attachment_id );
    348                 $image_meta['image_meta']['orientation'] = $saved_orientation;
     355                $image_meta['width']                     = $imagesize[0];
     356                $image_meta['height']                    = $imagesize[1];
     357
     358                $image_meta = _wp_make_additional_mime_types( $additional_mime_types, $file, $image_meta, $attachment_id );
     359
     360                // Restore the saved meta data.
     361                $image_meta['image_meta']['orientation'] = $saved_meta['orientation'];
     362                $image_meta['width']                     = $saved_meta['width'];
     363                $image_meta['height']                    = $saved_meta['height'];
    349364
    350365        }
Note: See TracChangeset for help on using the changeset viewer.