WordPress 3.5 comes with a new streamlined Media Manager which makes image insertion easy and image gallery making super easy. To make you feel right at home, here I will show you some tweaks that you can use to customize the new Media Upload box.
Remove Default Tabs in WordPress Media Manager
With this code you can remove any unwanted Tab or link in the Media Manager:
add_filter( 'media_view_strings', 'custom_media_uploader' ); function custom_media_uploader( $strings ) { unset( $strings['selected'] ); //Removes Upload Files & Media Library links in Insert Media tab unset( $strings['insertMediaTitle'] ); //Insert Media unset( $strings['uploadFilesTitle'] ); //Upload Files unset( $strings['mediaLibraryTitle'] ); //Media Library unset( $strings['createGalleryTitle'] ); //Create Gallery unset( $strings['setFeaturedImageTitle'] ); //Set Featured Image unset( $strings['insertFromUrlTitle'] ); //Insert from URL return $strings; }
Keep those strings that you want to remove, then add the code to your theme’s functions.php file.
If you prefer a cut down version of the Media Manager which allows only upload or selecting a file from the media library, then you can remove all those tab items to get a simple minimal look.
Add Custom Tab in WordPress Media Manager
After removing unnecessary tabs and links, if you want, you can add your own new custom tab for a new media file type or a plugin your’re making. For adding a new tab we’ll use media_upload_tabs
filter. It’s the same filter that was used to add tabs in the old thickbox media box. media_upload_tabs
filter is still well supported in WordPress, so you can count on it for the future.
So here’s the code:
function custom_media_upload_tab_name( $tabs ) { $newtab = array( 'tab_slug' => 'Your Tab Name' ); return array_merge( $tabs, $newtab ); } add_filter( 'media_upload_tabs', 'custom_media_upload_tab_name' ); function custom_media_upload_tab_content() { // Add you content here. } add_action( 'media_upload_tab_slug', 'custom_media_upload_tab_content' );
This will create a new tab in the Media Manager. Add the code you want to use in custom_media_upload_tab_content()
function.