Make WordPress Core

Changeset 37167


Ignore:
Timestamp:
04/08/2016 01:22:06 AM (9 years ago)
Author:
azaozz
Message:

Customizer: fix cropping of small images when setting header image, site icon or logo.

Props obenland.
Fixes #36412.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/customize-controls.js

    r37152 r37167  
    20982098                yInit = parseInt( control.params.height, 10 ),
    20992099                ratio = xInit / yInit,
    2100                 xImg  = realWidth,
    2101                 yImg  = realHeight,
     2100                xImg  = xInit,
     2101                yImg  = yInit,
    21022102                x1, y1, imgSelectOptions;
    21032103
    21042104            controller.set( 'canSkipCrop', ! control.mustBeCropped( flexWidth, flexHeight, xInit, yInit, realWidth, realHeight ) );
    21052105
    2106             if ( xImg / yImg > ratio ) {
    2107                 yInit = yImg;
     2106            if ( realWidth / realHeight > ratio ) {
     2107                yInit = realHeight;
    21082108                xInit = yInit * ratio;
    21092109            } else {
    2110                 xInit = xImg;
     2110                xInit = realWidth;
    21112111                yInit = xInit / ratio;
    21122112            }
    21132113
    2114             x1 = ( xImg - xInit ) / 2;
    2115             y1 = ( yImg - yInit ) / 2;
     2114            x1 = ( realWidth - xInit ) / 2;
     2115            y1 = ( realHeight - yInit ) / 2;
    21162116
    21172117            imgSelectOptions = {
     
    21222122                imageWidth: realWidth,
    21232123                imageHeight: realHeight,
     2124                minWidth: xImg > xInit ? xInit : xImg,
     2125                minHeight: yImg > yInit ? yInit : yImg,
    21242126                x1: x1,
    21252127                y1: y1,
     
    21312133                imgSelectOptions.aspectRatio = xInit + ':' + yInit;
    21322134            }
    2133             if ( flexHeight === false ) {
    2134                 imgSelectOptions.maxHeight = yInit;
    2135             }
    2136             if ( flexWidth === false ) {
    2137                 imgSelectOptions.maxWidth = xInit;
     2135
     2136            if ( true === flexHeight ) {
     2137                delete imgSelectOptions.minHeight;
     2138                imgSelectOptions.maxWidth = realWidth;
     2139            }
     2140
     2141            if ( true === flexWidth ) {
     2142                delete imgSelectOptions.minWidth;
     2143                imgSelectOptions.maxHeight = realHeight;
    21382144            }
    21392145
Note: See TracChangeset for help on using the changeset viewer.