WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#36236 closed defect (bug) (fixed)

JS error & odd behaviour when attempting to set image as 'site icon'

Reported by: davetgreen Owned by: ocean90
Milestone: 4.6 Priority: normal
Severity: normal Version: 4.4.2
Component: Customize Keywords: has-patch
Focuses: javascript Cc:
PR Number:

Description

When attempting to select an image for use with the 'site icon' feature in the customizer, the following JS error is generated:

b.trigger is not a function

Steps taken:

  1. Click on 'Select Image' in the Site Identity section of the Customize UI.

Upload brand new image to the media.

  1. Uploaded a brand new image, exactly 512px x 512px, 23kb file size, 72 DPI
  2. Hit 'Select'

The image is then de-selected in the media library, and nothing else happens except the generation of the above error in the console.

Tried in FF Dev Edition and latest stable Chrome.

Interestingly, if I close the Media Library, exit the Customize UI and then come back and try to Select Image again there are several files using the site-icon-cropped-X.jpg nomenclature that have been generated.

Clicking one of these images lets me actually select the image for use as the site-icon, the others have no effect.

Attachments (1)

36236.diff (537 bytes) - added by celloexpressions 4 years ago.

Download all attachments as: .zip

Change History (10)

#1 @westonruter
4 years ago

  • Keywords reporter-feedback added

@davetgreen what version of are you testing with? Is it 4.5-beta3 or is it 4.4.2? I cannot seem to reproduce the issue in trunk.

#2 @westonruter
4 years ago

Also, if you could add define( 'SCRIPT_DEBUG', true ); to your wp-config.php that will allow for a better error message to be generated, including the file and line number where the error is happening. Please share those details as well.

#3 @davetgreen
4 years ago

  • Version changed from trunk to 4.4.2

@westonruter Apologies, it's actually 4.4.2 I'm building this site with: I don't know why I flagged this as trunk!

With SCRIPT_DEBUG enabled...

controller.trigger is not a function

File: customize-controls.js
Row: 2249
Column: 6

Last edited 4 years ago by davetgreen (previous) (diff)

#4 @westonruter
4 years ago

  • Keywords reporter-feedback removed

OK, the issue is being triggered here: https://core.trac.wordpress.org/browser/tags/4.4.2/src/wp-admin/js/customize-controls.js?marks=2249#L2224

I'm not familiar enough with the Media Backbone to recognize immediately why this would fail. @ericlewis?

#5 @ericlewis
4 years ago

  • Focuses javascript added
  • Keywords reporter-feedback added

I'm not sure why it would fail either, but also not sure why controller.trigger would be undefined.

@davetgreen, can you reproduce the bug with all plugins disabled and a default theme active?

If so, can you attach the image you're uploading, and we'll see if we can reproduce.

#6 @adamsilverstein
4 years ago

@davetgreen Can you test against trunk to see if you can reproduce the issue there as well?

#7 @davetgreen
4 years ago

@ericlewis @adamsilverstein I'll be back to you with the results of these tests a bit later today.

#8 @celloexpressions
4 years ago

  • Keywords has-patch added; reporter-feedback removed
  • Milestone changed from Awaiting Review to 4.6

controller is supposed to be controller.frame in this case, see patch. controller is the customizer control object, but in this case it should actually be the media frame (controller.frame). I can confirm that this change prevents a JS error from being thrown, although it doesn't provide information on the error to the user. If nothing else though, let's get the JS error fix in.

#9 @ocean90
4 years ago

  • Owner set to ocean90
  • Resolution set to fixed
  • Status changed from new to closed

In 37955:

Customize: Use the correct variable when referring to the media frame.

Props celloexpressions.
Fixes #36236.

Note: See TracTickets for help on using tickets.