Changing the media library default tab

There’s a filter called media_upload_default_tab that you can use to do this.

<?php
add_filter('media_upload_default_tab', 'wpse74422_switch_tab');
function wpse74422_switch_tab($tab)
{
    return 'library';
}

You can set the to be whatever — assuming the tab exists. The tab keys themselves are found in the functon media_upload_tabs.

<?php
/**
 * Defines the default media upload tabs
 *
 * @since 2.5.0
 *
 * @return array default tabs
 */
function media_upload_tabs() {
    $_default_tabs = array(
        'type' => __('From Computer'), // handler action suffix => tab text
        'type_url' => __('From URL'),
        'gallery' => __('Gallery'),
        'library' => __('Media Library')
    );

    return apply_filters('media_upload_tabs', $_default_tabs);
}

So type (the original default), type_url, gallery, library and any custom tabs are up for grabs. Here is the above in plugin form.

One final note: the media work flow is changing significantly in WordPress 3.5 and this will no longer work. The good news, however, is that the new media popover is much more speedy and your problem is not likely to be an issue.

Leave a Comment