I released an update to WP Accessibility today, that adds some limited enforcement on alt attributes for images. It’s not as sophisticated as I’d like it to be, but it’s a start.

This includes five separate pieces:

  1. In the media manager, images include an indication that shows whether they have an alt text set or have been marked as decorative. If neither is true, it shows a link that points directly to the alt attribute field for editing.
  2. In the media editor and the insert media model, it inserts a checkbox to mark the image as decorative.
  3. If an image is inserted and the decorative checkbox is selected, then it automatically strips any alt attribute text out of the inserted image text.
  4. If an image is inserted and the decorative checkbox is not selected, then if the image has text in the alt field, everything happens normally. If not, the image is wrapped in an extra div, and text is appended to the image that indicates that the image needs alt text.
  5. Custom editor styles highlight the wrapper so that it’s more obvious as an error. The author then needs to take action to fix the content of their post.

What I’d like to have, in addition, is some scripting that can be attached to both the media modal and the media editor that will only allow you to save or insert the image if one of these two fields is set. But my JavaScript skills weren’t getting me there; so I’m releasing it as it is now, hoping that somebody with some sharper JS skills will step up and contribute!

Here’s looking for you…