How to open the add media dialogue it in a certain state / tab?

I created a customized wp_view similar to embed (see wp-includes/js/mce-view.js, l. 868). I also have my own tab in the "add media" dialog. Naturally I want the edit button of my wp_view opening the add media dialog with the right tab.

Currently I use this:

edit: function(text, update) {
    tb_show('Some headline', 'media-upload.php?tab=mytabsomeparams='+somevalues+'amp;TB_iframe=true');
}

I works like a charm, but

  • the edit and delete buttons keep staying in foreground, even before the thickbox.
  • in the codex is written:

    As of WordPress 3.5, the "Media" button for WordPress's post editor no longer utilizes ThickBox, but instead uses a custom Javascript modal.

So I really would prefer to use this custom modal. Is anyone able to explain me how to open the add media dialog it in a certain state (means tab)?

Topic media-modal media-library thickbox Wordpress javascript

Category Web


Suppose you want to open the modal to the create gallery section:

var options = {
frame: 'post',
       state: 'gallery',
       title: wp.media.view.l10n.createGalleryTitle,
       multiple: true
};

var frame = wp.media.editor.open(null,options)

If you want something else, I suggest you search through the core js source to change the Library ID as appropriate for the section you need.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.