# Ticket #18532: 18532.2.patch

File 18532.2.patch, 1.5 KB (added by SergeyBiryukov, 13 years ago)
• ## wp-includes/media.php

 \$smaller_ratio = min( \$width_ratio, \$height_ratio ); \$larger_ratio  = max( \$width_ratio, \$height_ratio ); if ( intval( \$current_width * \$larger_ratio ) > \$max_width || intval( \$current_height * \$larger_ratio ) > \$max_height ) if ( round( \$current_width * \$larger_ratio ) > \$max_width || round( \$current_height * \$larger_ratio ) > \$max_height ) // The larger ratio is too big. It would result in an overflow. \$ratio = \$smaller_ratio; else // The larger ratio fits, and is likely to be a more "snug" fit. \$ratio = \$larger_ratio; \$w = intval( \$current_width  * \$ratio ); \$h = intval( \$current_height * \$ratio ); \$w = round( \$current_width  * \$ratio ); \$h = round( \$current_height * \$ratio ); // Sometimes, due to rounding, we'll end up with a result like this: 465x700 in a 177x177 box is 117x176... a pixel short // 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. if ( \$did_height && \$h == \$max_height - 1 ) \$h = \$max_height; // Round it up return array( \$w, \$h ); return apply_filters( 'wp_constrain_dimensions', array( \$w, \$h ), \$current_width, \$current_height, \$max_width, \$max_height ); } /**