Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#32783 closed defect (bug) (fixed)

Ajax issue in the customizer when previewing a different theme

Reported by: Fab1en Owned by: westonruter
Priority: normal Milestone: 4.5
Component: Customize Version: 4.1
Severity: normal Keywords:
Cc: Focuses: javascript, administration

Description

When a theme is activated, and another one is previewed using the customizer live preview, ajax requests are run against the old theme, not the one being previewed.

The easiest way to see this issue is to use the Header Image cropping function included in core.

  1. Install and activate a theme that has no custom-header feature (for example Modern Estate)
  2. Go to the customizer, click on the change button to choose a new theme (for example, TwentyFifteen
  3. Use the Header Image panel to select and crop an image
  4. You get the following error : There has been an error cropping your image.
  5. Activate TwentyFifteen and crop the same image again : error has disappeared

If a theme defines specific ajax actions, those actions will not be available in the live preview until the theme is really activated.

Attachments (3)

32783.diff (687 bytes ) - added by rittesh.patel 10 years ago.
Patch to fix #32783
32783.2.diff (1.5 KB ) - added by faishal 10 years ago.
Without ajaxprefilter approach, by allowing crop ajax data to be overridden
32783.3.diff (1.6 KB ) - added by westonruter 10 years ago.
Minor style tweaks

Download all attachments as: .zip

Change History (15)

#1 @celloexpressions
11 years ago

  • Keywords needs-patch added

Probably should add the theme previewing logic to ajax calls, although I thought it already was. Needs investigating.

This ticket was mentioned in Slack in #core-customize by fab1en. View the logs.


11 years ago

#3 @westonruter
11 years ago

  • Milestone Awaiting Review4.5

Need to make sure the theme parameter is included in the Ajax requests.

#4 @westonruter
11 years ago

Note that generally in Core, Ajax requests initiated from the preview do not get the Customizer state applied. This has, however, been implemented in the transactions patch via jQuery.prefilter() to inject the Customizer transaction UUID. So this issue will be resolved there.

However, this issue is specific to an Ajax request created in the Customizer pane, and so I think it is included in the scope of transactions.

@rittesh.patel
10 years ago

Patch to fix #32783

@faishal
10 years ago

Without ajaxprefilter approach, by allowing crop ajax data to be overridden

#5 @westonruter
10 years ago

  • Keywords has-patch added; needs-patch removed

I like that approach, to hook into the underlying doCrop function, and extending an exposed doCropArgs to inject the additional args.

#6 @westonruter
10 years ago

  • Keywords dev-feedback added

@wonderboymusic thoughts on extending the wp.media.controller.Cropper.prototype.doCrop in this way?

This ticket was mentioned in Slack in #core by westonruter. View the logs.


10 years ago

#8 @kirasong
10 years ago

  • Owner set to westonruter
  • Status newassigned

@westonruter
10 years ago

Minor style tweaks

#9 @westonruter
10 years ago

  • Keywords dev-feedback removed

#10 @westonruter
10 years ago

  • Resolutionfixed
  • Status assignedclosed

In 36866:

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.

#11 @pento
10 years ago

  • Keywords has-patch removed
  • Resolution fixed
  • Status closedreopened

[36866] updated media-views.js, but didn't apply the change to controllers/cropper.js, which is causing grunt precommit:js to incorrectly remove the change from media-views.js.

#12 @pento
10 years ago

  • Resolutionfixed
  • Status reopenedclosed

In 36931:

Customize: Update cropper.js to match changes in [36866].

media-views.js was updated, but the changes weren't added to cropper.js, which caused the grunt precommit:js job to incorrectly remove the changes from media-views.js.

Fixes #32783.

Note: See TracTickets for help on using tickets.