Add filter to image_resize_dimensions() so plugins can perform this calculation on their own. props ebababi. fixes #15989.

git-svn-id: http://core.svn.wordpress.org/trunk@20694 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2012-05-02 20:15:44 +00:00
parent 803b3aa13a
commit fbea58a1b7

View File

@ -327,6 +327,8 @@ function wp_constrain_dimensions( $current_width, $current_height, $max_width=0,
* portion of the image will be cropped out and resized to the required size.
*
* @since 2.5.0
* @uses apply_filters() Calls 'image_resize_dimensions' on $orig_w, $orig_h, $dest_w, $dest_h and
* $crop to provide custom resize dimensions.
*
* @param int $orig_w Original width.
* @param int $orig_h Original height.
@ -343,6 +345,11 @@ function image_resize_dimensions($orig_w, $orig_h, $dest_w, $dest_h, $crop = fal
if ($dest_w <= 0 && $dest_h <= 0)
return false;
// plugins can use this to provide custom resize dimensions
$output = apply_filters( 'image_resize_dimensions', null, $orig_w, $orig_h, $dest_w, $dest_h, $crop );
if ( null !== $output )
return $output;
if ( $crop ) {
// crop the largest possible portion of the original image that we can size to $dest_w x $dest_h
$aspect_ratio = $orig_w / $orig_h;