Make WordPress Core

Changeset 13145


Ignore:
Timestamp:
02/14/2010 08:21:07 AM (15 years ago)
Author:
markjaquith
Message:

Skip intermediate sizes of a different aspect ratio than the original image when considering which image to use in image_get_intermediate_size(). fixes #12218

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/media.php

    r13140 r13145  
    485485                $data = $imagedata['sizes'][$_size];
    486486                if ( $data['width'] >= $size[0] || $data['height'] >= $size[1] ) {
     487                    // Skip images with unexpectedly divergent aspect ratios (crops)
     488                    // First, we calculate what size the original image would be if constrained to a box the size of the current image in the loop
     489                    $maybe_cropped = image_resize_dimensions($imagedata['width'], $imagedata['height'], $data['width'], $data['height'], false );
     490                    // If the size doesn't match exactly, then it is of a different aspect ratio, so we skip it, unless it's the thumbnail size
     491                    if ( 'thumbnail' != $_size && ( !$maybe_cropped || $maybe_cropped[0] != $data['width'] || $maybe_cropped[1] != $data['height'] ) )
     492                        continue;
     493                    // If we're still here, then we're going to use this size
    487494                    $file = $data['file'];
    488495                    list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size );
Note: See TracChangeset for help on using the changeset viewer.