Changeset 36031 for trunk/src/wp-includes/media.php
- Timestamp:
- 12/20/2015 02:38:34 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r35820 r36031 1016 1016 $image_baseurl = trailingslashit( $image_baseurl ); 1017 1017 1018 // Calculate the image aspect ratio.1019 $image_ratio = $image_height / $image_width;1020 1021 1018 /* 1022 1019 * Images that have been edited in WordPress after being uploaded will … … 1055 1052 } 1056 1053 1057 // Calculate the new image ratio. 1058 if ( $image['width'] ) { 1059 $image_ratio_compare = $image['height'] / $image['width']; 1054 /** 1055 * To check for varying crops, we calculate the expected size of the smaller 1056 * image if the larger were constrained by the width of the smaller and then 1057 * see if it matches what we're expecting. 1058 */ 1059 if ( $image_width > $image['width'] ) { 1060 $constrained_size = wp_constrain_dimensions( $image_width, $image_height, $image['width'] ); 1061 $expected_size = array( $image['width'], $image['height'] ); 1060 1062 } else { 1061 $image_ratio_compare = 0; 1062 } 1063 1064 // If the new ratio differs by less than 0.002, use it. 1065 if ( abs( $image_ratio - $image_ratio_compare ) < 0.002 ) { 1063 $constrained_size = wp_constrain_dimensions( $image['width'], $image['height'], $image_width ); 1064 $expected_size = array( $image_width, $image_height ); 1065 } 1066 1067 // If the image dimensions are within 1px of the expected size, use it. 1068 if ( abs( $constrained_size[0] - $expected_size[0] ) <= 1 && abs( $constrained_size[1] - $expected_size[1] ) <= 1 ) { 1066 1069 // Add the URL, descriptor, and value to the sources array to be returned. 1067 1070 $sources[ $image['width'] ] = array(
Note: See TracChangeset
for help on using the changeset viewer.