Make WordPress Core

Opened 12 years ago

Closed 10 years ago

Last modified 10 years ago

#22925 closed defect (bug) (invalid)

media_upload_tabs filter not functioning

Reported by: kegster's profile kegster Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5
Component: Media Keywords:
Focuses: Cc:


When using the media_upload_tabs filter, the array passed through contains a 'library' item that usually can be unset, therefore removing the Media Library tab from the front-end uploader. This no longer works. I cannot even rename the labels using this method, however the array of tabs is still coming through, and modifying it does nothing. The filter is still active, but appears to do nothing.

Change History (5)

#1 @kegster
12 years ago

This happened as of the 3.5 upgrade, of course.

#2 @SergeyBiryukov
12 years ago

  • Component changed from General to Media

#3 @kirasong
10 years ago

  • Keywords reporter-feedback added

Hi kegster!

Apologies that it took so long for a reply.

This filter is effectively deprecated, along with the old-style media uploader, as it only applies to the previous media upload modal, and not the new one.

Is the filter not working for you when you're using it to modify the old-style modal, or is the issue that you can't modify the tabs of the new media modal with this filter?

#4 @ericlewis
10 years ago

  • Keywords reporter-feedback removed
  • Resolution set to invalid
  • Status changed from new to closed

I can confirm media_upload_tabs still works for the old media modal.



// Remove the URL tab
add_filter( 'media_upload_tabs', function($tabs ) {
    unset( $tabs['type_url'] );
    return $tabs;
} );

 * All code by: A.Morita
 * URL:

 * Old upload Thickbox
add_action( 'admin_head', 'remove_media_buttons' );

function remove_media_buttons()
    remove_action( 'media_buttons', 'media_buttons' );
    add_action( 'media_buttons', 'old_media_buttons' );

function old_media_buttons( $editor_id = 'content' )
    $context = apply_filters( 'media_buttons_context', __('Upload/Insert %s') );

    $img = '<img src="'
        . esc_url( admin_url( 'images/media-button.png?ver=20111005' ) )
        . '" width="15" height="15" />';

    echo '<a href="'
        . esc_url( get_upload_iframe_src() )
        . '" class="thickbox add_media" id="'
        . esc_attr( $editor_id )
        . '-add_media" title="'
        . esc_attr__( 'Add Media' )
        . '" onclick="return false;">'
        . sprintf( $context, $img )
        . '</a>';

 * Featured image
add_action( 'wp_default_scripts', 'unset_media_views', 999, 1 );
add_action( 'admin_head', 'remove_wp_print_media_templates' );

function unset_media_views($scripts)
    unset( $scripts->registered['media-views'] );

function remove_wp_print_media_templates()
    remove_action( 'admin_footer', 'wp_print_media_templates' );
    remove_action( 'wp_footer', 'wp_print_media_templates' );

 * Adjust Full Screen behavior
add_action( 'after_wp_tiny_mce', 'fullscreen_media_button' );

function fullscreen_media_button()
    <script type="text/javascript">
    fullscreen.medialib = function()
        var href = jQuery('div#wp-content-media-buttons a.thickbox').attr('href') || '';
        tb_show('', href);

Modifying the new tabs is a bit more tricky, keep an eye on my Backbone media documentation plugin for an example of that sometime soon.

Closing out, feel free to reopen if there's more to it.

#5 @DrewAPicture
10 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.