WP 3.5 media manager – how to create a working gallery frame

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)

Read More

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

Related posts

Leave a Reply

1 comment