WordPress.org

Make WordPress Core

Ticket #18532: 18532.patch

File 18532.patch, 1.0 KB (added by SergeyBiryukov, 7 years ago)
  • wp-includes/media.php

     
    301301                // The larger ratio fits, and is likely to be a more "snug" fit.
    302302                $ratio = $larger_ratio;
    303303
    304         $w = intval( $current_width  * $ratio );
    305         $h = intval( $current_height * $ratio );
     304        $w = round( $current_width  * $ratio );
     305        $h = round( $current_height * $ratio );
    306306
    307307        // Sometimes, due to rounding, we'll end up with a result like this: 465x700 in a 177x177 box is 117x176... a pixel short
    308308        // We also have issues with recursive calls resulting in an ever-changing result. Contraining to the result of a constraint should yield the original result.
     
    312312        if ( $did_height && $h == $max_height - 1 )
    313313                $h = $max_height; // Round it up
    314314
    315         return array( $w, $h );
     315        return apply_filters( 'wp_constrain_dimensions', array( $w, $h ), $current_width, $current_height, $max_width, $max_height );
    316316}
    317317
    318318/**