Changeset 56411 for trunk/src/wp-admin/includes/image-edit.php
- Timestamp:
- 08/18/2023 10:07:25 AM (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/image-edit.php
r56400 r56411 33 33 $backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true ); 34 34 $can_restore = false; 35 35 36 if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) { 36 37 $can_restore = wp_basename( $meta['file'] ) !== $backup_sizes['full-orig']['file']; … … 898 899 } 899 900 900 $f width = ! empty( $_REQUEST['fwidth'] ) ? (int) $_REQUEST['fwidth'] : 0;901 $f height = ! empty( $_REQUEST['fheight'] ) ? (int) $_REQUEST['fheight'] : 0;902 $target = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : '';903 $scale = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do'];901 $full_width = ! empty( $_REQUEST['fwidth'] ) ? (int) $_REQUEST['fwidth'] : 0; 902 $full_height = ! empty( $_REQUEST['fheight'] ) ? (int) $_REQUEST['fheight'] : 0; 903 $target = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : ''; 904 $scale = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do']; 904 905 905 906 /** This filter is documented in wp-admin/includes/image-edit.php */ … … 907 908 908 909 if ( $scale ) { 909 $size = $img->get_size();910 $ sX= $size['width'];911 $ sY= $size['height'];912 913 if ( $ sX < $fwidth || $sY < $fheight ) {910 $size = $img->get_size(); 911 $original_width = $size['width']; 912 $original_height = $size['height']; 913 914 if ( $full_width > $original_width || $full_height > $original_height ) { 914 915 $return->error = esc_js( __( 'Images cannot be scaled to a size larger than the original.' ) ); 915 916 return $return; 916 917 } 917 918 918 if ( $f width > 0 && $fheight > 0 ) {919 if ( $full_width > 0 && $full_height > 0 ) { 919 920 // Check if it has roughly the same w / h ratio. 920 $diff = round( $ sX / $sY, 2 ) - round( $fwidth / $fheight, 2 );921 $diff = round( $original_width / $original_height, 2 ) - round( $full_width / $full_height, 2 ); 921 922 if ( -0.1 < $diff && $diff < 0.1 ) { 922 923 // Scale the full size image. 923 if ( $img->resize( $f width, $fheight ) ) {924 if ( $img->resize( $full_width, $full_height ) ) { 924 925 $scaled = true; 925 926 }
Note: See TracChangeset
for help on using the changeset viewer.