WordPress.org

Make WordPress Core

Changeset 36866


Ignore:
Timestamp:
03/06/2016 01:44:53 AM (4 years ago)
Author:
westonruter
Message:

Customize: Fix image cropping when doing live preview of theme switches.

Ensure that the Customizer gets bootstrapped with the pre-activated theme supplied in the custom-header-crop admin ajax requests.

Props faishal, rittesh.patel.
Fixes #32783.

Location:
trunk/src
Files:
2 edited

Legend:

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

    r36851 r36866  
    23472347                api.HeaderTool.DefaultsList
    23482348            ]);
     2349
     2350            // Ensure custom-header-crop Ajax requests bootstrap the Customizer to activate the previewed theme.
     2351            wp.media.controller.Cropper.prototype.defaults.doCropArgs.wp_customize = 'on';
     2352            wp.media.controller.Cropper.prototype.defaults.doCropArgs.theme = api.settings.theme.stylesheet;
    23492353        },
    23502354
  • trunk/src/wp-includes/js/media-views.js

    r36575 r36866  
    283283        content:     'crop',
    284284        router:      false,
    285 
    286         canSkipCrop: false
     285        canSkipCrop: false,
     286
     287        // Default doCrop Ajax arguments to allow the Customizer (for example) to inject state.
     288        doCropArgs: {}
    287289    },
    288290
     
    368370
    369371    doCrop: function( attachment ) {
    370         return wp.ajax.post( 'custom-header-crop', {
    371             nonce: attachment.get('nonces').edit,
    372             id: attachment.get('id'),
    373             cropDetails: attachment.get('cropDetails')
    374         } );
     372        return wp.ajax.post( 'custom-header-crop', _.extend(
     373            {},
     374            this.defaults.doCropArgs,
     375            {
     376                nonce: attachment.get( 'nonces' ).edit,
     377                id: attachment.get( 'id' ),
     378                cropDetails: attachment.get( 'cropDetails' )
     379            }
     380        ) );
    375381    }
    376382});
Note: See TracChangeset for help on using the changeset viewer.