WordPress.org

Make WordPress Core

Ticket #12218: only_croped_images_for_thumbnails.diff

File only_croped_images_for_thumbnails.diff, 1.3 KB (added by dd32, 8 years ago)
  • wp-includes/media.php

     
    434434                                'file' => basename( $resized_file ),
    435435                                'width' => $info[0],
    436436                                'height' => $info[1],
     437                                'crop' => $crop
    437438                        );
    438439                }
    439440        }
     
    460461 * @param array|string $size Optional, default is 'thumbnail'. Size of image, either array or string.
    461462 * @return bool|array False on failure or array of file path, width, and height on success.
    462463 */
    463 function image_get_intermediate_size($post_id, $size='thumbnail') {
     464function image_get_intermediate_size($post_id, $size = 'thumbnail' ) {
    464465        if ( !is_array( $imagedata = wp_get_attachment_metadata( $post_id ) ) )
    465466                return false;
    466467
     468        $croped_ok = ( in_array($size, array('thumbnail', 'post-thumbnail')) && get_option('thumbnail_crop') );
     469
    467470        // get the best one for a specified set of dimensions
    468471        if ( is_array($size) && !empty($imagedata['sizes']) ) {
    469472                foreach ( $imagedata['sizes'] as $_size => $data ) {
     473                        if ( !$croped_ok && !empty($data['crop']) )
     474                                continue;
    470475                        // already cropped to width or height; so use this size
    471476                        if ( ( $data['width'] == $size[0] && $data['height'] <= $size[1] ) || ( $data['height'] == $size[1] && $data['width'] <= $size[0] ) ) {
    472477                                $file = $data['file'];