Removing fields from the Media Uploader/Gallery

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.

Leave a Comment