| 660 | | // Skip images with unexpectedly divergent aspect ratios (crops) |
| 661 | | // First, we calculate what size the original image would be if constrained to a box the size of the current image in the loop |
| 662 | | $maybe_cropped = image_resize_dimensions($imagedata['width'], $imagedata['height'], $data['width'], $data['height'], false ); |
| 663 | | // 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 |
| 664 | | if ( 'thumbnail' != $_size && |
| 665 | | ( ! $maybe_cropped |
| 666 | | || ( $maybe_cropped[4] != $data['width'] && $maybe_cropped[4] + 1 != $data['width'] ) |
| 667 | | || ( $maybe_cropped[5] != $data['height'] && $maybe_cropped[5] + 1 != $data['height'] ) |
| 668 | | ) ) { |
| 669 | | continue; |
| | 665 | // Skip images with unexpectedly divergent aspect ratios (crops) |
| | 666 | // First, we calculate what size the original image would be if constrained to a box the size of the current image in the loop |
| | 667 | $maybe_cropped = image_resize_dimensions($imagedata['width'], $imagedata['height'], $data['width'], $data['height'], false ); |
| | 668 | // 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 |
| | 669 | if ( 'thumbnail' != $_size && |
| | 670 | ( ! $maybe_cropped |
| | 671 | || ( $maybe_cropped[4] != $data['width'] && $maybe_cropped[4] + 1 != $data['width'] ) |
| | 672 | || ( $maybe_cropped[5] != $data['height'] && $maybe_cropped[5] + 1 != $data['height'] ) |
| | 673 | ) ) { |
| | 674 | continue; |
| | 675 | } |
| | 676 | // If we're still here, then we're going to use this size. |
| | 677 | list( $data['width'], $data['height'] ) = image_constrain_size_for_editor( $data['width'], $data['height'], $size ); |
| | 678 | |
| | 679 | /** This filter is documented in wp-includes/media.php */ |
| | 680 | return apply_filters( 'image_get_intermediate_size', $data, $post_id, $size ); |