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.


git-svn-id: https://develop.svn.wordpress.org/trunk@36866 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter 2016-03-06 01:44:53 +00:00
parent 6d01e8650c
commit 52d50a6ce9
2 changed files with 16 additions and 6 deletions

View File

@ -2346,6 +2346,10 @@
api.HeaderTool.UploadsList,
api.HeaderTool.DefaultsList
]);
// Ensure custom-header-crop Ajax requests bootstrap the Customizer to activate the previewed theme.
wp.media.controller.Cropper.prototype.defaults.doCropArgs.wp_customize = 'on';
wp.media.controller.Cropper.prototype.defaults.doCropArgs.theme = api.settings.theme.stylesheet;
},
/**

View File

@ -282,8 +282,10 @@ Cropper = wp.media.controller.State.extend({
toolbar: 'crop',
content: 'crop',
router: false,
canSkipCrop: false,
canSkipCrop: false
// Default doCrop Ajax arguments to allow the Customizer (for example) to inject state.
doCropArgs: {}
},
activate: function() {
@ -367,11 +369,15 @@ Cropper = wp.media.controller.State.extend({
},
doCrop: function( attachment ) {
return wp.ajax.post( 'custom-header-crop', {
return wp.ajax.post( 'custom-header-crop', _.extend(
{},
this.defaults.doCropArgs,
{
nonce: attachment.get( 'nonces' ).edit,
id: attachment.get( 'id' ),
cropDetails: attachment.get( 'cropDetails' )
} );
}
) );
}
});