WordPress.org

Make WordPress Core

Ticket #7748: wp-includes-media.php.patch

File wp-includes-media.php.patch, 724 bytes (added by miqrogroove, 6 years ago)

Fixes flawed cropping logic and inconsistent type juggling.

  • wp-includes/media.php

     
    281281 
    282282                $size_ratio = max($new_w / $orig_w, $new_h / $orig_h); 
    283283 
    284                 $crop_w = ceil($new_w / $size_ratio); 
    285                 $crop_h = ceil($new_h / $size_ratio); 
     284                $crop_w = intval(round($new_w / $size_ratio)); 
     285                $crop_h = intval(round($new_h / $size_ratio)); 
    286286 
    287                 $s_x = floor(($orig_w - $crop_w)/2); 
    288                 $s_y = floor(($orig_h - $crop_h)/2); 
     287                $s_x = intval(($orig_w - $crop_w)/2); 
     288                $s_y = intval(($orig_h - $crop_h)/2); 
    289289        } 
    290290        else { 
    291291                // don't crop, just resize using $dest_w x $dest_h as a maximum bounding box