Using WordPress ‘media_upload_tabs()’ PHP function

The media_upload_tabs WordPress PHP function defines the default media upload tabs.

Usage

$default_tabs = media_upload_tabs();

Parameters

  • None

More information

See WordPress Developer Resources: media_upload_tabs

This is a 2.5.0 filter. You can also use a newer filter (3.5.0) to achieve the same: media_view_settings

Examples

Add a new tab to the media upload modal

Add a new tab called “Photogrid” to the media upload modal.

add_filter('media_view_settings', 'add_photogrid_tab');
function add_photogrid_tab($settings) {
    $settings['tabs'] = array('photogrid' => 'Photogrid');
    return $settings;
}

Remove the “Insert from URL” tab

Remove the “Insert from URL” tab from the media upload modal.

add_filter('media_upload_tabs', 'remove_insert_from_url_tab');
function remove_insert_from_url_tab($tabs) {
    unset($tabs['type_url']);
    return $tabs;
}

Change the default tab

Change the default tab in the media upload modal to “Create Gallery.”

add_filter('media_upload_default_tab', 'change_default_media_tab');
function change_default_media_tab() {
    return 'gallery';
}

Remove all default tabs and add a custom one

Remove all default tabs and add a custom “My Custom Tab” to the media upload modal.

add_filter('media_upload_tabs', 'custom_media_upload_tabs');
function custom_media_upload_tabs($tabs) {
    $tabs = array('my_custom_tab' => 'My Custom Tab');
    return $tabs;
}

Reorder the tabs

Reorder the tabs in the media upload modal.

add_filter('media_upload_tabs', 'reorder_media_upload_tabs');
function reorder_media_upload_tabs($tabs) {
    $new_tabs = array(
        'gallery' => $tabs['gallery'],
        'type' => $tabs['type'],
        'type_url' => $tabs['type_url'],
    );
    return $new_tabs;
}