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?

  • 1
    This would be very bad for your site: the alt attribute is reserved for a functional equivalent of the image. It cannot be the same as the title. Just imagine you were forced to use a screen reader and had to listen to each title twice.
    – fuxia
    Commented Nov 16, 2012 at 23:40
  • Have you read the article linked at? wordpress.stackexchange.com/q/5645/5424. Using the pre 3.5 uploader this should work.
    – user5424
    Commented Nov 17, 2012 at 6:31
  • @toscho My problem is that most users leave the alt field empty, which is a bigger issue for SEO and accessibility. Using this approach I can at least ensure there will be some alt text, and either disable the title field completely in the output or auto-populate it.
    – Sam
    Commented Nov 20, 2012 at 20:16

1 Answer 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 );
  • 999 is an exaggeration... 11 is enough, 15 just to be sure :)
    – brasofilo
    Commented Nov 17, 2012 at 10:38
  • Perfect! Didn't realize I could change the priority, though it looked like that was causing the issue. Works great now.
    – Sam
    Commented Nov 20, 2012 at 20:12
  • 4
    Is this still relevant? I am running 3.9.1 and this code does not work for me.
    – 3x5
    Commented May 27, 2014 at 17:01
  • 2
    Looks like they killed this filter in 3.6 without really telling anyone. It is still there, but as far as I can tell it can now only be used to add fields, not to unset. I spent a good while looking for a way to do it, but ended up using simple CSS hiding (oh, the shame!).
    – Olemak
    Commented Feb 19, 2016 at 13:23
  • @ThatBrazilianGuy, your edit was ok but why did you put that weird edit summary??
    – brasofilo
    Commented May 2, 2017 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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