Customize the wordpress Upload interface
- Date
- August 13th, 2011
- Category
- Development
- Tags
- wordpress
- Discussion
- 5 Comments
WordPress can be customized a lot if you are ready to get your hands dirty with the functions.php file. This is useful to unclutter the interface for your less computer-savvy users, and basically, to reduce the complexity of their experience as much as possible (less complexity, less chance to make errors and experiment frustration).
One of the interfaces they’ll probably use a lot is the one that appears when they want to add an image or media file: the “Add an attachment” screen.
Add This function to your theme’s functions.php to hide all fields that you want to hide to your “author” users
function remove_attachment_fields($form_fields) {
if ( substr( $post->post_mime_type, 0, 5 ) == ‘image’) {
$form_fields['image_description']['input'] = 'hidden';
if (current_user_can('author')){
// Alternative text
$form_fields['image_alt']['value'] = '';
$form_fields['image_alt']['input'] = 'hidden';
// Description
$form_fields['post_excerpt']['value'] = '';
$form_fields['post_excerpt']['input'] = 'hidden';
// Title
$form_fields['post_title']['value'] = '';
$form_fields['post_title']['input'] = 'hidden';
$form_fields['post_content']['value'] = '';
$form_fields['post_content']['input'] = 'hidden';
// Url associated to the image's click behaviour
$form_fields['url']['value'] = '';
$form_fields['url']['input'] = 'hidden';
// image alignment
$form_fields['align']['value'] = 'aligncenter';
$form_fields['align']['input'] = 'hidden';
// image size that will be injected inside your post content if you insert it
$form_fields['image-size']['value'] = 'thumbnail';
$form_fields['image-size']['input'] = 'hidden';
$form_fields['image-caption']['value'] = 'caption';
$form_fields['image-caption']['input'] = 'hidden';
$form_fields['buttons']['input'] = 'hidden';
return $form_fields;
}
}
}
add_filter('attachment_fields_to_edit','remove_attachment_fields', 15, 2);
Hi and thanks for the tips. I am trying to solve a similar problem (adding text to the ‘Upload media from computer’ screen. See But i haven´t found a solution yet. Any tips?
Hi torbjörn,
Perhaps this tutorial on Creating custom fields for attachments in WordPress could help? http://net.tutsplus.com/tutorials/wordpress/creating-custom-fields-for-attachments-in-wordpress/
Hello. I wanted to thank you for this. It was exactly what I needed.
There is a tiny typo however. Line 2 should read:
if ( substr( $post->post_mime_type, 0, 5 ) == ‘image’) {
thank you again.
Thanks a lot Hasan, corrected.
Hey, i wrote something about the wordpress uploader (with drag and drop ajax functionality you can check it out : http://bit.ly/H5KJYt )