| 594 | | if ( $data['width'] >= $size[0] || $data['height'] >= $size[1] ) { |
| 595 | | // Skip images with unexpectedly divergent aspect ratios (crops) |
| 596 | | // First, we calculate what size the original image would be if constrained to a box the size of the current image in the loop |
| 597 | | $maybe_cropped = image_resize_dimensions($imagedata['width'], $imagedata['height'], $data['width'], $data['height'], false ); |
| 598 | | // If the size doesn't match within one pixel, then it is of a different aspect ratio, so we skip it, unless it's the thumbnail size |
| 599 | | if ( 'thumbnail' != $_size && ( !$maybe_cropped || ( $maybe_cropped[4] != $data['width'] && $maybe_cropped[4] + 1 != $data['width'] ) || ( $maybe_cropped[5] != $data['height'] && $maybe_cropped[5] + 1 != $data['height'] ) ) ) |
| 600 | | continue; |
| 601 | | // If we're still here, then we're going to use this size |
| 602 | | $file = $data['file']; |
| 603 | | list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size ); |
| 604 | | return compact( 'file', 'width', 'height' ); |
| 605 | | } |
| | 598 | // Skip images with unexpectedly divergent aspect ratios (crops) |
| | 599 | // First, we calculate what size the original image would be if constrained to a box the size of the current image in the loop |
| | 600 | $maybe_cropped = image_resize_dimensions($imagedata['width'], $imagedata['height'], $data['width'], $data['height'], false ); |
| | 601 | // If the size doesn't match within one pixel, then it is of a different aspect ratio, so we skip it, unless it's the thumbnail size |
| | 602 | if ( 'thumbnail' != $_size && |
| | 603 | ( !$maybe_cropped |
| | 604 | || ( $maybe_cropped[4] != $data['width'] && $maybe_cropped[4] + 1 != $data['width'] ) |
| | 605 | || ( $maybe_cropped[5] != $data['height'] && $maybe_cropped[5] + 1 != $data['height'] ) |
| | 606 | ) ) |
| | 607 | continue; |
| | 608 | // If we're still here, then we're going to use this size |
| | 609 | $file = $data['file']; |
| | 610 | list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size ); |
| | 611 | return compact( 'file', 'width', 'height' ); |