Skip to content

Commit

Permalink
Return WP_Error from wp_crop_image() if saving has failed. props macb…
Browse files Browse the repository at this point in the history
…rink. fixes #23325.

git-svn-id: http://core.svn.wordpress.org/trunk@23374 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
SergeyBiryukov committed Feb 2, 2013
1 parent 2cb5fcc commit 2967871
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion wp-admin/includes/image.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 2967871

Please sign in to comment.