290 | | return array( intval($current_width * $ratio), intval($current_height * $ratio) ); |
| 295 | if ( intval( $current_width * $larger_ratio ) > $max_width || intval( $current_height * $larger_ratio ) > $max_height ) |
| 296 | // The larger ratio is too big. It would result in an overflow. |
| 297 | $ratio = $smaller_ratio; |
| 298 | else |
| 299 | // The larger ratio fits, and is likely to be a more "snug" fit. |
| 300 | $ratio = $larger_ratio; |
| 301 | |
| 302 | $w = intval( $current_width * $ratio ); |
| 303 | $h = intval( $current_height * $ratio ); |
| 304 | |
| 305 | // Sometimes, due to rounding, we'll end up with a result like this: 465x700 in a 177x177 box is 117x176... a pixel short |
| 306 | // We also have issues with recursive calls resulting in an ever-changing result. Contraining to the result of a constraint should yield the original result. |
| 307 | // Thus we look for dimensions that are one pixel shy of the max value and bump them up |
| 308 | if ( isset( $did_width ) && $did_width && $w == $max_width - 1 ) |
| 309 | $w = $max_width; // Round it up |
| 310 | if ( isset( $did_height ) && $did_height && $h == $max_height - 1 ) |
| 311 | $h = $max_height; // Round it up |
| 312 | |
| 313 | return array( $w, $h ); |
524 | | // 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 |
525 | | if ( 'thumbnail' != $_size && ( !$maybe_cropped || $maybe_cropped[4] != $data['width'] || $maybe_cropped[5] != $data['height'] ) ) |
| 547 | // 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 |
| 548 | 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'] ) ) ) |