WordPress.org

Make WordPress Core

Ticket #17626: media.php.diff

File media.php.diff, 1.2 KB (added by chipbennett, 3 years ago)

slight modification to image_get_intermediate_size()

  • media.php

     
    529529        // get the best one for a specified set of dimensions 
    530530        if ( is_array($size) && !empty($imagedata['sizes']) ) { 
    531531                foreach ( $imagedata['sizes'] as $_size => $data ) { 
     532                        // already cropped exactly to width and height; so use this size 
     533                        if ( $data['width'] == $size[0] && $data['height'] == $size[1] ) { 
     534                                $file = $data['file']; 
     535                                list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size ); 
     536                                return compact( 'file', 'width', 'height' ); 
     537                        } 
    532538                        // already cropped to width or height; so use this size 
    533                         if ( ( $data['width'] == $size[0] && $data['height'] <= $size[1] ) || ( $data['height'] == $size[1] && $data['width'] <= $size[0] ) ) { 
     539                        else if ( ( $data['width'] == $size[0] && $data['height'] <= $size[1] ) || ( $data['height'] == $size[1] && $data['width'] <= $size[0] ) ) { 
    534540                                $file = $data['file']; 
    535541                                list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size ); 
    536542                                return compact( 'file', 'width', 'height' );