In the WordPress admin screen, when working in the post or page editor, you will see some media upload buttons above the TinyMCE editor. If you would like to hide them from your client, for example to disable the upload of such files, you can follow the steps below:
To Remove All Media Buttons
[php]
add_action(‘admin_init’, ‘remove_all_media_buttons’);
function remove_all_media_buttons()
{
remove_all_actions(‘media_buttons’);
}
[/php]
To Remove Only Some Buttons
In this case we need to add an admin stylesheet, so in your functions.php file paste the following:
[php]
add_action(‘admin_init’, ‘my_admin_stylesheet’);
function my_admin_stylesheet()
{
wp_enqueue_style(‘my_admin’, get_bloginfo(‘template_url’).’/css/my_admin.css’);
}
[/php]
Then create a file called my_admin.css within the ‘css’ folder of your theme, and insert the following:
[css]
<code>/* Hide the buttons you want */
#add_image { display:none; }
#add_video { display:none; }
#add_audio { display:none; }
#add_media { display:none; }
[/css]
If you enjoyed this post, make sure to subscribe to WPMayor’s RSS feed.
4 Responses
Thanks for this Jean!
I was looking for a filter hook to remove this and wasn’t having any luck since the only test to prevent it from rendering is “if( !current_user_can(‘upload_files’))” and trying to hook anything involved with the checking didn’t work. (not sure what I was missing)
After giving Google a go, I found your post and it worked like a charm!
The only catch I see is it still requires adding CSS to hide the container div for it (at least in the 3.3-dev version), but at least the buttons are gone.
Thanks again.
Glad to be of help!
Thanks for the tip on removing the GUI buttons. Since it requires a custom css, does this work for if the user might happen to switch themes? (I’m trying to prevent upload). And also does it prevent access to media from the left nav bar, or just the editor?
It prevents access from just the editor, with this method it will stop working when user switches themes.