Make WordPress Core

Changeset 12524


Ignore:
Timestamp:
12/23/2009 06:39:31 PM (17 years ago)
Author:
ryan
Message:

Retunr WP_Error from wp_crop_image() and image_resize(). Props mdwaffe. fixes #9922

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/custom-header.php

    r11383 r12524  
    361361                        $oitar = $width / HEADER_IMAGE_WIDTH;
    362362                        $image = wp_crop_image($file, 0, 0, $width, $height, HEADER_IMAGE_WIDTH, $height / $oitar, false, str_replace(basename($file), 'midsize-'.basename($file), $file));
     363                        if ( is_wp_error( $image ) )
     364                                wp_die( __( 'Image could not be processed.  Please go back and try again.' ), __( 'Image Processing Error' ) );
     365
    363366                        $image = apply_filters('wp_create_file_in_uploads', $image, $id); // For replication
    364367
    … …  
    415418
    416419                $cropped = wp_crop_image($_POST['attachment_id'], $_POST['x1'], $_POST['y1'], $_POST['width'], $_POST['height'], HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT);
     420                if ( is_wp_error( $cropped ) )
     421                        wp_die( __( 'Image could not be processed.  Please go back and try again.' ), __( 'Image Processing Error' ) );
     422
    417423                $cropped = apply_filters('wp_create_file_in_uploads', $cropped, $_POST['attachment_id']); // For replication
    418424
  • trunk/wp-admin/includes/image.php

    r12351 r12524  
    3939 * @param int $src_abs Optional. If the source crop points are absolute.
    4040 * @param string $dst_file Optional. The destination file to write to.
    41  * @return string New filepath on success, String error message on failure.
     41 * @return string|WP_Error|false New filepath on success, WP_Error or false on failure.
    4242 */
    4343function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) {
    … …  
    4747        $src = wp_load_image( $src_file );
    4848
    49         if ( !is_resource( $src ))
    50                 return $src;
     49        if ( !is_resource( $src ) )
     50                return new WP_Error( 'error_loading_image', $src, $src_file );
    5151
    5252        $dst = wp_imagecreatetruecolor( $dst_w, $dst_h );
  • trunk/wp-includes/media.php

    r12411 r12524  
    356356        $image = wp_load_image( $file );
    357357        if ( !is_resource( $image ) )
    358                 return new WP_Error('error_loading_image', $image);
     358                return new WP_Error( 'error_loading_image', $image, $file );
    359359
    360360        $size = @getimagesize( $file );
Note: See TracChangeset for help on using the changeset viewer.