Make WordPress Core

Ticket #48489: 48489.diff

File 48489.diff, 1.9 KB (added by psrpinto, 2 years ago)
  • src/wp-admin/includes/image.php

    diff --git src/wp-admin/includes/image.php src/wp-admin/includes/image.php
    index b3b68560b4..c32dcec49c 100644
    function wp_create_image_subsizes( $file, $attachment_id ) { 
    249249        // Do not scale (large) PNG images. May result in sub-sizes that have greater file size than the original. See #48736.
    250250        if ( 'image/png' !== $imagesize['mime'] ) {
    251251
     252                $threshold = 2560;
     253
     254                // If there are registered image sizes with a value greater than the default threshold,
     255                // use that value instead of the default. See https://core.trac.wordpress.org/ticket/48489.
     256                foreach ( wp_get_registered_image_subsizes() as $subsize ) {
     257                        if ( $subsize['width'] > $threshold ) {
     258                                $threshold = $subsize['width'];
     259                        }
     260                        if ( $subsize['height'] > $threshold ) {
     261                                $threshold = $subsize['height'];
     262                        }
     263                }
     264
    252265                /**
    253266                 * Filters the "BIG image" threshold value.
    254267                 *
    function wp_create_image_subsizes( $file, $attachment_id ) { 
    260273                 *
    261274                 * @since 5.3.0
    262275                 *
    263                  * @param int    $threshold     The threshold value in pixels. Default 2560.
     276                 * @param int    $threshold     The threshold value in pixels. Default 2560 or the maximum registered image size.
    264277                 * @param array  $imagesize     {
    265278                 *     Indexed array of the image width and height in pixels.
    266279                 *
    function wp_create_image_subsizes( $file, $attachment_id ) { 
    270283                 * @param string $file          Full path to the uploaded image file.
    271284                 * @param int    $attachment_id Attachment post ID.
    272285                 */
    273                 $threshold = (int) apply_filters( 'big_image_size_threshold', 2560, $imagesize, $file, $attachment_id );
     286                $threshold = (int) apply_filters( 'big_image_size_threshold', $threshold, $imagesize, $file, $attachment_id );
    274287
    275288                // If the original image's dimensions are over the threshold,
    276289                // scale the image and use it as the "full" size.