I've been searching high and low for an answer.

I simply want to remove the Alternate Text, Caption, Description and Link URL-fields from the uploader and gallery view.

I seem that every thing else than this Media-thingy can be removed.

Thanx for helping out:)


You can do this via a filter. Add the following to functions.php. You can also add your own fields this way...

// edit fields in media upload area
add_filter('attachment_fields_to_edit', 'remove_media_upload_fields', 10000, 2);
function remove_media_upload_fields( $form_fields, $post ) {

    // remove unnecessary fields
    unset( $form_fields['image-size'] );
    unset( $form_fields['post_excerpt'] );
    unset( $form_fields['post_content'] );
    unset( $form_fields['url'] );
    unset( $form_fields['image_url'] );
    unset( $form_fields['align'] );

    return $form_fields;

The example above strips out more than you need to but if you do a print_r() on the $form_fields variable you'll see what's available to add/remove.

| improve this answer | |
  • 1
    Doesn't appear to work any more. $form_fields is empty for this filter. – funwhilelost Apr 3 '13 at 19:11
  • Doesn't work on WP 3.5+ – That Brazilian Guy Apr 26 '17 at 18:42

Unfortunately it looks like this changed quite a bit in WP3.5 when they upgraded the media library. That filter's $form_fields parameter doesn't contain the defaults any more. The only solution I've found so far is to forcibly remove the markup from the view using buffering:

This is extremely fragile - any change to the WordPress core might break this

function wpse45562_remove_media_fields( $buffer ) {
    // remove the 'caption' block
    $buffer = preg_replace( '~<p>\s*<label\s*for="attachment_caption">.*?</p>~ims', '', $buffer );
    // remove the 'alt text' block
    $buffer = preg_replace( '~<p>\s*<label\s*for="attachment_alt">.*?</p>~ims', '', $buffer );

    // remove the 'description' box (and label separately)
    $buffer = preg_replace( '~<div\s*id="wp-attachment_content-editor.*?</div>~ims', '',   $buffer );
    $buffer = preg_replace( '~<label\s*for="content">.*?</label>~ims', '', $buffer );

    return $buffer;

function wpse45562_media_strip_buffer_start() { ob_start("wpse45562_remove_media_fields");  }
function wpse45562_media_strip_buffer_end() { ob_end_flush(); }

add_action('admin_head', 'wpse45562_media_strip_buffer_start', 10, 1);
add_action('admin_footer', 'wpse45562_media_strip_buffer_end', 10, 1);
| improve this answer | |
  • I think there a some filters in the js backbone templates where the fields get added we might be able to co-opt. It certainly isn't straightforward any more though :( – sanchothefat Apr 4 '13 at 9:27
  • I agree. For now I've opened a ticket over on Trac. If they're going to make it the same as any other post it should respond to remove_post_type_support(), at least. – funwhilelost Apr 4 '13 at 21:43
  • Wouldn't this approach affect caching? – That Brazilian Guy Apr 26 '17 at 18:45
  • @ThatBrazilianGuy - I'm not sure what you mean. These fields are displayed in the dashboard. Having empty values for the media will not affect the caching. – funwhilelost Apr 26 '17 at 22:49

The sanchothefat's Answer is correct, really Works like a charm.

Just for increase his answer, you can use unset( $form_fields['image_alt'] ); to remove the Alternate Text.

Thanks for Answering sanchothefat, it Helped me.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.