From fbea58a1b7d8bb5f515d71f1eb0fe4d77d5af335 Mon Sep 17 00:00:00 2001 From: nacin Date: Wed, 2 May 2012 20:15:44 +0000 Subject: [PATCH] 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 --- wp-includes/media.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wp-includes/media.php b/wp-includes/media.php index 55c2fbd3e0..63cdfbda8d 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -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;