From 30650e32bed1bb7de82fe6087f6fe010bed4d343 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 2 Feb 2013 02:01:59 +0000 Subject: [PATCH] Return WP_Error from wp_crop_image() if saving has failed. props macbrink. fixes #23325. git-svn-id: https://develop.svn.wordpress.org/trunk@23374 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/image.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index c0fdfd9c23..a842287094 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -20,7 +20,7 @@ * @param int $dst_h The destination height. * @param int $src_abs Optional. If the source crop points are absolute. * @param string $dst_file Optional. The destination file to write to. - * @return string|WP_Error|false New filepath on success, WP_Error or false on failure. + * @return string|WP_Error New filepath on success, WP_Error on failure. */ function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) { $src_file = $src; @@ -54,6 +54,9 @@ function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $s $dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), basename( $dst_file ) ); $result = $editor->save( $dst_file ); + if ( is_wp_error( $result ) ) + return $result; + return $dst_file; }