Make WordPress Core

Ticket #22738: 22738.2.diff

File 22738.2.diff, 1.2 KB (added by nacin, 11 years ago)
  • wp-includes/media.php

     
    13751375
    13761376                                // Nothing from the filter, so consult image metadata if we have it.
    13771377                                $size_meta = $meta['sizes'][ $size ];
     1378
     1379                                // We have the actual image size, but might need to further constrain it if content_width is narrower.
     1380                                // This is not necessary for thumbnails and medium size.
     1381                                if ( 'thumbnail' == $size || 'medium' == $size ) {
     1382                                        $width = $size_meta['width'];
     1383                                        $height = $size_meta['height'];
     1384                                } else {
     1385                                        list( $width, $height ) = image_constrain_size_for_editor( $size_meta['width'], $size_meta['height'], $size );
     1386                                }
     1387
    13781388                                $sizes[ $size ] = array(
    1379                                         'height'      => $size_meta['height'],
    1380                                         'width'       => $size_meta['width'],
     1389                                        'height'      => $height,
     1390                                        'width'       => $width,
    13811391                                        'url'         => $base_url . $size_meta['file'],
    1382                                         'orientation' => $size_meta['height'] > $size_meta['width'] ? 'portrait' : 'landscape',
     1392                                        'orientation' => $height > $width ? 'portrait' : 'landscape',
    13831393                                );
    13841394                        }
    13851395                }