WordPress.org

Make WordPress Core

Ticket #19118: media.php.patch

File media.php.patch, 1.2 KB (added by mzaweb, 4 years ago)

moved the validation to image_resize

  • wp-includes/media.php

     
    375375                list( $new_w, $new_h ) = wp_constrain_dimensions( $orig_w, $orig_h, $dest_w, $dest_h ); 
    376376        } 
    377377 
    378         // if the resulting image would be the same size or larger we don't want to resize it 
    379         if ( $new_w >= $orig_w && $new_h >= $orig_h ) 
    380                 return false; 
    381  
    382378        // the return array matches the parameters to imagecopyresampled() 
    383379        // int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h 
    384380        return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h ); 
     
    423419                return new WP_Error( 'error_getting_dimensions', __('Could not calculate resized image dimensions') ); 
    424420        list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = $dims; 
    425421 
     422    // if the resulting image would be the same size or larger we don't want to resize it 
     423        if ( $dst_w >= $orig_w && $dst_h >= $orig_h ) 
     424                return $file; 
     425 
    426426        $newimage = wp_imagecreatetruecolor( $dst_w, $dst_h ); 
    427427 
    428428        imagecopyresampled( $newimage, $image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);