Consistently return WP_Error on failure in image_resize. props filosofo, fixes #12268

git-svn-id: http://svn.automattic.com/wordpress/trunk@14105 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-04-16 13:53:22 +00:00
parent 757d3ba8ae
commit 207a1d6958
1 changed files with 2 additions and 2 deletions

View File

@ -376,7 +376,7 @@ function image_resize_dimensions($orig_w, $orig_h, $dest_w, $dest_h, $crop = fal
* @param string $suffix Optional. File Suffix. * @param string $suffix Optional. File Suffix.
* @param string $dest_path Optional. New image file path. * @param string $dest_path Optional. New image file path.
* @param int $jpeg_quality Optional, default is 90. Image quality percentage. * @param int $jpeg_quality Optional, default is 90. Image quality percentage.
* @return mixed WP_Error on failure. String with new destination path. Array of dimensions from {@link image_resize_dimensions()} * @return mixed WP_Error on failure. String with new destination path.
*/ */
function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) { function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) {
@ -391,7 +391,7 @@ function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $de
$dims = image_resize_dimensions($orig_w, $orig_h, $max_w, $max_h, $crop); $dims = image_resize_dimensions($orig_w, $orig_h, $max_w, $max_h, $crop);
if ( !$dims ) if ( !$dims )
return $dims; return new WP_Error( 'error_getting_dimensions', __('Could not calculate resized image dimensions') );
list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = $dims; list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = $dims;
$newimage = wp_imagecreatetruecolor( $dst_w, $dst_h ); $newimage = wp_imagecreatetruecolor( $dst_w, $dst_h );