Changeset 7041 for trunk/wp-admin/includes/image.php
- Timestamp:
- 02/26/2008 06:46:03 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/image.php
r6952 r7041 226 226 function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) { 227 227 return wp_constrain_dimensions( $width, $height, $wmax, $hmax ); 228 }229 230 // same as wp_shrink_dimensions, except the max parameters are optional.231 // if either width or height are empty, no constraint is applied on that dimension.232 function wp_constrain_dimensions( $current_width, $current_height, $max_width=0, $max_height=0 ) {233 if ( !$max_width and !$max_height )234 return array( $current_width, $current_height );235 236 $width_ratio = $height_ratio = 1.0;237 238 if ( $max_width > 0 && $current_width > $max_width )239 $width_ratio = $max_width / $current_width;240 241 if ( $max_height > 0 && $current_height > $max_height )242 $height_ratio = $max_height / $current_height;243 244 // the smaller ratio is the one we need to fit it to the constraining box245 $ratio = min( $width_ratio, $height_ratio );246 247 return array( intval($current_width * $ratio), intval($current_height * $ratio) );248 228 } 249 229
Note: See TracChangeset
for help on using the changeset viewer.