diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index 5c0d0a40fa..5c21af6be4 100644 --- a/src/wp-admin/js/customize-controls.js +++ b/src/wp-admin/js/customize-controls.js @@ -2097,22 +2097,22 @@ xInit = parseInt( control.params.width, 10 ), yInit = parseInt( control.params.height, 10 ), ratio = xInit / yInit, - xImg = realWidth, - yImg = realHeight, + xImg = xInit, + yImg = yInit, x1, y1, imgSelectOptions; controller.set( 'canSkipCrop', ! control.mustBeCropped( flexWidth, flexHeight, xInit, yInit, realWidth, realHeight ) ); - if ( xImg / yImg > ratio ) { - yInit = yImg; + if ( realWidth / realHeight > ratio ) { + yInit = realHeight; xInit = yInit * ratio; } else { - xInit = xImg; + xInit = realWidth; yInit = xInit / ratio; } - x1 = ( xImg - xInit ) / 2; - y1 = ( yImg - yInit ) / 2; + x1 = ( realWidth - xInit ) / 2; + y1 = ( realHeight - yInit ) / 2; imgSelectOptions = { handles: true, @@ -2121,6 +2121,8 @@ persistent: true, imageWidth: realWidth, imageHeight: realHeight, + minWidth: xImg > xInit ? xInit : xImg, + minHeight: yImg > yInit ? yInit : yImg, x1: x1, y1: y1, x2: xInit + x1, @@ -2130,11 +2132,15 @@ if ( flexHeight === false && flexWidth === false ) { imgSelectOptions.aspectRatio = xInit + ':' + yInit; } - if ( flexHeight === false ) { - imgSelectOptions.maxHeight = yInit; + + if ( true === flexHeight ) { + delete imgSelectOptions.minHeight; + imgSelectOptions.maxWidth = realWidth; } - if ( flexWidth === false ) { - imgSelectOptions.maxWidth = xInit; + + if ( true === flexWidth ) { + delete imgSelectOptions.minWidth; + imgSelectOptions.maxHeight = realHeight; } return imgSelectOptions;