Set alt tag for img if there is figure caption

Suggest to add alt tag when adding an image through the admin interface (not markdown) with a figure caption. It will be useful for seo.

I wrote a line of code, test it and it works.

file Ghost/core/server/lib/mobiledoc/cards/image.js line 39

        if (!payload.alt) {
            img.setAttribute('alt', payload.caption);

I cant commit in repo, so maybe somebody who can will take this.

@konstaner this isn’t a good use of alt tags. If you do that then it means text is repeated unnecessarily for anyone using assistive tech like screen readers, it’s also unusual for captions to describe what’s in an image which is the intended use of alt tags. It’s better to have alt="" in the case where you have a caption but no specific alt text, especially as the caption is already semantically linked to the image via the <figure> and <figcaption> elements. WebAIM is a good resource for proper alt text implementation.

This being said, I think accessibility is something we all need to work on more and consider more on the internet in general. If you’ve ever had the opportunity to sit with someone who is blind using a computer, its honestly a pretty horrible experience on most sites. If we could add the ability to add image alt tags in the Ghost editor that would be really nice.

That’s been here for a little while now :slight_smile: UI for editing alt text in image cards was added to the editor in Ghost 2.26.0.


Oh dang! Thanks Kevin! Can’t believe I missed this…

1 Like