Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#35181 closed defect (bug) (invalid)

Using Lodash makes media_upload dialog unable to use

Reported by: anhntbk08 Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4
Component: Media Keywords: close
Focuses: Cc:


I'm writing a plugin with Angular and Wordpress. When i declared https://lodash.com/ the media_upload is unable to use. Medias will be shown up but you can't Pick them and the 'select' event will not be fired.

There is no error on javascript.

var frame = wp.media.frames.file_frame = wp.media({
            library: {
              type: 'image'
            frame: 'select',
            multiple: true

// this won't be triggered
frame.on('select', function () {

If i remove lodash, everything is ok.


Change History (2)

#1 @swissspidy
6 years ago

  • Keywords close added

WordPress uses Underscore.js for the media modal. It uses the same _ variable as Lodash.

You need to use Lodash's noConflict mode in your application to prevent it from overwriting the variable:

var lodash = _.noConflict();

#2 @johnbillion
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.