Media: Store and reuse image cropper ratio settings if available, instead of overwriting.
Props adamsilverstein. Fixes #42646. git-svn-id: https://develop.svn.wordpress.org/trunk@42595 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
47f6031fbd
commit
4dec1ad477
@ -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');
|
||||
|
@ -55,18 +55,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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user