Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

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

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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