[wp-hackers] Alt text for images wrong or empty in wp_get_attachment_image()

Karl Wångstedt maillist at wangstedt.net
Sun Jan 10 02:31:16 UTC 2010

Hi all

I have found a bug in 2.9 where the alt-text for images called via wp_get_attachment_image() is missing or wrong. The function generates the alt-text from the post_excerpt field instead of the (new) postmeta field with meta_key "_wp_attachment_image_alt". This causes the alt text to not be set even though the media editor clearly states that the "Alternate text" field is being used as alt text for the image.

I have committed a bug and a patch to trac here: http://core.trac.wordpress.org/ticket/11846

There could be a good thing to expand the function to check if the alt-text is set, and if not use the post_excerpt for the image instead. If neither the alt-text nor caption is set the title should be used as alt-text.

I think it it is an accessibility problem if the alt-text is left empty. Especially since the title is required for the image in the media uploader.

Please review the trac entry and see what you guys think.

Karl Wångstedt

More information about the wp-hackers mailing list