i am writing a plugin and after hours and hours of searching for any documentation on WP 3.5 media manager i managed to create my custom media frame that is being called when a user clicks on a custom TinyMCE button in that i added. this is the working code that inserts a single image:
onclick: function(e) {
var dej_frame;
e.preventDefault();
// If the frame already exists, re-open it.
if (dej_frame) {
dej_frame.open();
return;
}
//create media frame
dej_frame = wp.media.frames.dej_frame = wp.media({
className: 'media-frame mojo-media-frame',
frame: 'post',
multiple: false,
state: 'insert',
library: {
type: 'image' //Only allow images
},
});
dej_frame.on('insert', function() {
var media_attachment = dej_frame.state().get('selection').first().toJSON();
ed.execCommand('mceInsertContent', false, 'this will be instered in editor');
});
dej_frame.open();
}
This is working for single image. But, when i try to add gallery nothing happens. I do not know and couldn’t find in the source (it’s either too confusing or i am too stupid for this)
I know that i need to write my own function that will add galleries, only i don’t know what’s the actual name of the function, how should it be called??
I found this plugin. It provides a pretty good example of how to integrate the new Media UI with the admin, and is very well documented:
https://github.com/thomasgriffin/New-Media-Image-Uploader/
Maybe that can help you.