Opened 12 years ago
Closed 12 years ago
#22495 closed defect (bug) (fixed)
Localize media-popup.js?
Reported by: | bradyvercher | Owned by: | koopersmith |
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | normal | Version: | 3.5 |
Component: | Media | Keywords: | |
Focuses: | Cc: |
Description
Some plugins that enqueue media-upload.js in the dashboard are throwing a javascript error in the beta: ReferenceError: _wpMediaViewsL10n is not defined.
This can be reproduced by implementing the following code and visiting any dashboard page that doesn't include the media upload functionality by default:
add_action( 'admin_enqueue_scripts', 'media_upload_js_test' ); function media_upload_js_test() { wp_enqueue_script( 'media-upload' ); }
Change History (6)
#2
follow-up:
↓ 3
@
12 years ago
Seems that the right way to include the media upload functionality on a page is to call wp_enqueue_media()
instead of enqueueing the scripts directly:
http://core.trac.wordpress.org/browser/trunk/wp-includes/media.php?rev=22647#L1299
#3
in reply to:
↑ 2
@
12 years ago
Replying to SergeyBiryukov:
Seems that the right way to include the media upload functionality on a page is to call
wp_enqueue_media()
instead of enqueueing the scripts directly.
You're correct. We should add some graceful fallbacks for the l10n
variable to make sure things don't break when media-upload.js
is enqueued as a dependency, though.
#4
@
12 years ago
The example from the description actually produces two errors:
Timestamp: 19.11.2012 4:31:28 Error: ReferenceError: _wpMediaViewsL10n is not defined Source File: http://trunk.wordpress/wp-includes/js/media-views.js?ver=3.5-beta3-22645 Line: 9 Timestamp: 19.11.2012 4:31:28 Error: TypeError: wp.media.view.settings is undefined Source File: http://trunk.wordpress/wp-admin/js/media-upload.js?ver=3.5-beta3-22645 Line: 218
Also reported in the forum: http://wordpress.org/support/topic/35-beta-3-load-scripts-error-when-enqueuing-media-upload?replies=1