Customize: Respect aspect ratio on cropped images.
Takes into account whether the control supports `flex_width` and/or `flex_height` and adjusts destination measurements accordingly. Fixes #36318. Built from https://develop.svn.wordpress.org/trunk@37113 git-svn-id: http://core.svn.wordpress.org/trunk@37080 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
bfd19e92f5
commit
1edaf1c357
|
@ -400,13 +400,18 @@ var Controller = wp.media.controller,
|
|||
CustomizeImageCropper = Controller.Cropper.extend({
|
||||
doCrop: function( attachment ) {
|
||||
var cropDetails = attachment.get( 'cropDetails' ),
|
||||
control = this.get( 'control' );
|
||||
control = this.get( 'control' ),
|
||||
ratio = cropDetails.width / cropDetails.height;
|
||||
|
||||
if ( ! control.params.flex_width ) {
|
||||
cropDetails.dst_width = control.params.width;
|
||||
}
|
||||
if ( ! control.params.flex_height ) {
|
||||
cropDetails.dst_height = control.params.height;
|
||||
// Use crop measurements when flexible in both directions.
|
||||
if ( control.params.flex_width && control.params.flex_height ) {
|
||||
cropDetails.dst_width = cropDetails.width;
|
||||
cropDetails.dst_height = cropDetails.height;
|
||||
|
||||
// Constrain flexible side based on image ratio and size of the fixed side.
|
||||
} else {
|
||||
cropDetails.dst_width = control.params.flex_width ? control.params.height * ratio : control.params.width;
|
||||
cropDetails.dst_height = control.params.flex_height ? control.params.width / ratio : control.params.height;
|
||||
}
|
||||
|
||||
return wp.ajax.post( 'crop-image', {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.5-RC1-37112';
|
||||
$wp_version = '4.5-RC1-37113';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue