Media: Store and reuse image cropper ratio settings if available, instead of overwriting.

Props adamsilverstein.
Fixes #42646.
Built from https://develop.svn.wordpress.org/trunk@42595


git-svn-id: http://core.svn.wordpress.org/trunk@42424 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2018-01-24 21:36:31 +00:00
parent 4d89f4a20c
commit 365c70d415
3 changed files with 18 additions and 8 deletions

View File

@ -9168,18 +9168,28 @@ Cropper = View.extend(/** @lends wp.media.view.Cropper.prototype */{
imgOptions = _.extend(imgOptions, {
parent: this.$el,
onInit: function() {
this.parent.children().on( 'mousedown touchstart', function( e ){
if ( e.shiftKey ) {
// Store the set ratio.
var setRatio = imgSelect.getOptions().aspectRatio;
// On mousedown, if no ratio is set and the Shift key is down, use a 1:1 ratio.
this.parent.children().on( 'mousedown touchstart', function( e ) {
// If no ratio is set and the shift key is down, use a 1:1 ratio.
if ( ! setRatio && e.shiftKey ) {
imgSelect.setOptions( {
aspectRatio: '1:1'
} );
} else {
imgSelect.setOptions( {
aspectRatio: false
} );
}
} );
this.parent.children().on( 'mouseup touchend', function( e ) {
// Restore the set ratio.
imgSelect.setOptions( {
aspectRatio: setRatio ? setRatio : false
} );
} );
}
} );
this.trigger('image-loaded');

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.0-alpha-42594';
$wp_version = '5.0-alpha-42595';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.