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;

    // If the frame already exists, re-open it.
    if (dej_frame) {

    //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');



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??

  • 2
    No you're not stupid, the 3.5 media documentation does not exists, have you tried settings multiple: true, .
    – Wyck
    Apr 3, 2013 at 1:32
  • Take a look at WooCommerce. They are inserting multiple images this and I just borrowed the code for my own metabox. Apr 3, 2013 at 8:24

1 Answer 1


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:


Maybe that can help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.