Remove “Insert from URL” link in Media upload – WP 3.5

How do I remove the Insert from URL link in the new WordPress 3.5 Add Media popup page? In earlier versions of WordPress, this worked fine:

// removes URL tab in image upload for post
function remove_media_library_tab($tabs) { 
    if (isset($_REQUEST['post_id'])) {
        $post_type = get_post_type($_REQUEST['post_id']);
        if ('premium' == $post_type)
            unset($tabs['library']);
            unset($tabs['type_url']);
    }
    return $tabs;
}
add_filter('media_upload_tabs', 'remove_media_library_tab');

Who knows?

Related posts

Leave a Reply

2 comments

  1. This should work:

    add_filter( 'media_view_strings', 'cor_media_view_strings' );
    /**
     * Removes the media 'From URL' string.
     *
     * @see wp-includes|media.php
     */
    function cor_media_view_strings( $strings ) {
        unset( $strings['insertFromUrlTitle'] );
        return $strings;
    }
    
  2. The code of default tabs array in new WP is in media.php and looks like this:

    /**
     * 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);
    }
    

    If you want only remove upload from url by default you shoud change your function to:

    // removes URL tab in image upload for post
    function remove_media_library_tab($tabs) { 
        unset($tabs['type_url']);
        return $tabs;
    }
    add_filter('media_upload_tabs', 'remove_media_library_tab');
    

    Not tested but it should work fine.

    Edit: Not work because this array is used in other place.
    If you want just remove the link you can use this work around:

    function remove_media_library_tab(){
        ?>
        <style>
            .media-menu a:last-child{ display:none}
        </style>
        <?php
    }
    add_action('admin_head', 'remove_media_library_tab');