diff --git a/src/js/_enqueues/lib/image-edit.js b/src/js/_enqueues/lib/image-edit.js
index 18d3099f62c..7ce5d242e92 100644
a
|
b
|
|
226 | 226 | */ |
227 | 227 | scaleChanged : function( postid, x, el ) { |
228 | 228 | var w = $('#imgedit-scale-width-' + postid), h = $('#imgedit-scale-height-' + postid), |
229 | | warn = $('#imgedit-scale-warn-' + postid), w1 = '', h1 = ''; |
| 229 | warn = $('#imgedit-scale-warn-' + postid), w1 = '', h1 = '', |
| 230 | scaleBtn = $('#imgedit-scale-button'); |
230 | 231 | |
231 | 232 | if ( false === this.validateNumeric( el ) ) { |
232 | 233 | return; |
… |
… |
|
242 | 243 | |
243 | 244 | if ( ( h1 && h1 > this.hold.oh ) || ( w1 && w1 > this.hold.ow ) ) { |
244 | 245 | warn.css('visibility', 'visible'); |
| 246 | scaleBtn.prop('disabled', true); |
245 | 247 | } else { |
246 | 248 | warn.css('visibility', 'hidden'); |
| 249 | scaleBtn.prop('disabled', false); |
247 | 250 | } |
248 | 251 | }, |
249 | 252 | |
diff --git a/src/wp-admin/includes/image-edit.php b/src/wp-admin/includes/image-edit.php
index e814fc47e78..ddb4781b7d4 100644
a
|
b
|
function wp_save_image( $post_id ) { |
845 | 845 | $target = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : ''; |
846 | 846 | $scale = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do']; |
847 | 847 | |
848 | | if ( $scale && $fwidth > 0 && $fheight > 0 ) { |
| 848 | if ( $scale ) { |
849 | 849 | $size = $img->get_size(); |
850 | 850 | $sX = $size['width']; |
851 | 851 | $sY = $size['height']; |
852 | 852 | |
853 | | // Check if it has roughly the same w / h ratio. |
854 | | $diff = round( $sX / $sY, 2 ) - round( $fwidth / $fheight, 2 ); |
855 | | if ( -0.1 < $diff && $diff < 0.1 ) { |
856 | | // Scale the full size image. |
857 | | if ( $img->resize( $fwidth, $fheight ) ) { |
858 | | $scaled = true; |
859 | | } |
| 853 | if ( $sX < $fwidth || $sY < $fheight ) { |
| 854 | $return->error = esc_js( __( 'Images cannot be scaled to a size larger than the original.' ) ); |
| 855 | return $return; |
860 | 856 | } |
861 | 857 | |
862 | | if ( ! $scaled ) { |
863 | | $return->error = esc_js( __( 'Error while saving the scaled image. Please reload the page and try again.' ) ); |
864 | | return $return; |
| 858 | if ( $fwidth > 0 && $fheight > 0 ) { |
| 859 | // Check if it has roughly the same w / h ratio. |
| 860 | $diff = round( $sX / $sY, 2 ) - round( $fwidth / $fheight, 2 ); |
| 861 | if ( -0.1 < $diff && $diff < 0.1 ) { |
| 862 | // Scale the full size image. |
| 863 | if ( $img->resize( $fwidth, $fheight ) ) { |
| 864 | $scaled = true; |
| 865 | } |
| 866 | } |
| 867 | |
| 868 | if ( ! $scaled ) { |
| 869 | $return->error = esc_js( __( 'Error while saving the scaled image. Please reload the page and try again.' ) ); |
| 870 | return $return; |
| 871 | } |
865 | 872 | } |
866 | 873 | } elseif ( ! empty( $_REQUEST['history'] ) ) { |
867 | 874 | $changes = json_decode( wp_unslash( $_REQUEST['history'] ) ); |