WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 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:

Description

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
          });
frame.off('select');
frame.open();

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

If i remove lodash, everything is ok.

Thanks

Change History (2)

#1 @swissspidy
5 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
5 years ago

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