How to use WordPress 3.5 media manager gallery tool for my own plugin How to use WordPress 3.5 media manager gallery tool for my own plugin wordpress wordpress

How to use WordPress 3.5 media manager gallery tool for my own plugin


You can call a = wp.media.gallery.edit('[gallery ids="2,1,3..."]'); like Wordpress does in media-editor.js.

I wasn't sure what event can catch the update, I found it with a.on('all',function(n,a) {console.log(n); console.log(a)})

Notice "update" in the log, and an object with a models array with the images. So, the quickest solutions using the gallery selector would be:

wp.media.gallery.edit('[gallery ids="numberlist"]').on('update',function(obj)  { do something with obj.models)})