Using the WordPress 3.5 Media Uploader window as a modal popup

I have a general question: is it possible to use the new WordPress 3.5 Media Uploader window for other purposes (i.e., as a modal popup window for content)? I would like to do this and have spent a lot of time trying to figure out if/how to do it but have had NO luck.

I’m basically looking to replace the Thickbox popup as the way my shortcode panel is presented in the admin panel.

Read More

Has anyone done this or something similar? Can anyone point me to something that covers this or some variation on the theme?

Many thanks,

Andrew.

Related posts

Leave a Reply

1 comment

  1. You can try the following script:

    var MEDIAmedia_library: function() {
         var formfield = null;
    
         var wireframe;
    
         $('body').on('click', '#click-event-selector',function(e) {
             e.preventDefault();
             if (wireframe) {
                 wireframe.open();
                 return;
             }
    
             wireframe = wp.media.frames.wireframe = wp.media({
                 title: 'Media Library Title',
                 button: {
                     text: 'Media Library Button Title'
                 },
                 multiple: false
             });
    
             wireframe.on('select', function() {
                 attachment = wireframe.state().get('selection').first().toJSON();
                 console.log(attachment);
                 $('#input-field-selector').val(attachment.url);
             });
    
             wireframe.open();
         });
        }
    

    #click-event-selector your click event selector

    #input-field-selector your input field value to insert selected object properties

    You can also wrap this function in any jquery modal

    Reference WordPress 3.5 Media Uploader