How can I remove the image attachment ALT field?

I’ve been using the technique described in this post to remove the caption and description fields in the uploads modal window, thus eliminating unused clutter for users. Since the title field is already required when uploading images in WordPress, it’s easiest for my users to dispense with the alt field altogether and just pull the alt text from the title field when displaying images on a website.

From what I’m seeing in the media.php file, I should be able to unset the alt field by adding this to my function: unset($form_fields['image_alt']);, but it’s not working. Any suggestions as to what I might be doing wrong?

Related posts

Leave a Reply

1 comment

  1. Considering that you will come up with a solution to the accessibility issue pointed by @toscho…

    Putting a lower priority (later execution) to the filter does the job.

    $priority (integer) (optional)
    Used to specify the order in which the
    functions associated with a particular action are executed. Lower
    numbers correspond with earlier execution, and functions with the same
    priority are executed in the order in which they were added to the
    action.
    Default: 10

    function remove_caption( $fields ) {
        unset( $fields['image_alt'] );
        return $fields;
    }
    add_filter( 'attachment_fields_to_edit', 'remove_caption', 999, 1 );