To simplify the Media Library layout to users when uploading an image, sometimes i hide the following fields:
function myAttachmentFields($form_fields, $post) {
if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
$form_fields['image_alt']['value'] = '';
$form_fields['image_alt']['input'] = 'hidden';
$form_fields['post_excerpt']['value'] = '';
$form_fields['post_excerpt']['input'] = 'hidden';
$form_fields['post_content']['value'] = '';
$form_fields['post_content']['input'] = 'hidden';
$form_fields['url']['value'] = '';
$form_fields['url']['input'] = 'hidden';
$form_fields['align']['value'] = 'aligncenter';
$form_fields['align']['input'] = 'hidden';
$form_fields['image-size']['value'] = 'thumbnail';
$form_fields['image-size']['input'] = 'hidden';
$form_fields['image-caption']['value'] = 'caption';
$form_fields['image-caption']['input'] = 'hidden';
}
return $form_fields;
}
add_filter('attachment_fields_to_edit', 'myAttachmentFields');
Question:
How do I hide the Insert into post button and the Set image text link.
Thanks in advance
Jose, give this a shot and see if that’s the kind of thing you had in mind..
EDIT: Done a little bit of testing and copying of core code to archieve this, but i think the new example i’ve added below should do what you’ve described, remove the buttons, “Insert into Post”, etc…, but keep a delete link. I’ve left the original example i provided because it may be useful to someone.
New Example
Remove buttons, but keep a delete link
Original Example
Example of how to remove all buttons, but provide an insert into post button.
Set the filter to priorty 15, so it’s hooked on after WordPress has hooked it’s own filters on(because it adds them at the default priority of 10).
Not sure you wanted the insert button, just wanted to give an example of replacing the original buttons with a singular insert one..
Hope that helps..