How to call WP3.5 Media Library manager?

The question:

In the past Media Library window could be called like this:

tb_show("Upload image", "media-upload.php?type=image&TB_iframe=1&width=640&height=520");

This still works in WP3.5. But I’m wondering how to open a new media manager? It’s no longer handled by Thickbox – tb_show().

Thanks for any advices!

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

From the article How to use WordPress 3.5 Media Uploader in Theme Options (by, as seen in Using the WordPress 3.5 Media Uploader within plugins (by Mike Jolley’s article has quite some nice tricks.

Important note: if the page where the uploader is going to be used doesn’t already have all media JS APIs, then wp_enqueue_media() has to be called.

So, supposing we have a button like this in a custom Meta Box:

<div class="uploader">
      <input type="text" name="settings[_wpse_82857]" id="_wpse_82857" />
      <input class="button" name="_wpse_82857_button" id="_wpse_82857_button" value="Upload" />

The following script will call the new uploader and fill up the input text field #_wpse_82857 with the attachment path when Insert into post is clicked.

    var _custom_media = true,
        _orig_send_attachment =;

    // ADJUST THIS to match the correct button
    $('.uploader .button').click(function(e) 
        var send_attachment_bkp =;
        var button = $(this);
        var id = button.attr('id').replace('_button', '');
        _custom_media = true; = function(props, attachment)
            if ( _custom_media ) 
            } else {
                return _orig_send_attachment.apply( this, [props, attachment] );
        return false;

    $('.add_media').on('click', function()
        _custom_media = false;

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment