# Set alt tag for img if there is figure caption

**URL:** <https://forum.ghost.org/t/set-alt-tag-for-img-if-there-is-figure-caption/6753>\
**Category:** Ideas\
**Tags:** 🚧-rejected\
**Created:** [April 10, 2019, 12:29pm UTC](https://forum.ghost.org/t/set-alt-tag-for-img-if-there-is-figure-caption/6753 "2019-04-10T12:29:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![konstaner](https://avatars.discourse-cdn.com/v4/letter/k/a698b9/32.png) [@konstaner](https://forum.ghost.org/u/konstaner)\
**Post date:** [April 10, 2019, 12:29pm UTC](https://forum.ghost.org/t/set-alt-tag-for-img-if-there-is-figure-caption/6753/1 "2019-04-10T12:29:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kevin/32/32_2.png) [@Kevin](https://forum.ghost.org/u/Kevin)\
**Post date:** [August 5, 2019, 11:21am UTC](https://forum.ghost.org/t/set-alt-tag-for-img-if-there-is-figure-caption/6753/2 "2019-08-05T11:21:42Z")

</div>

@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](https://webaim.org/techniques/alttext/).

---

<div class="post-metadata">

**Author:** ![willston](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/willston/32/3836_2.png) [@willston](https://forum.ghost.org/u/willston)\
**Post date:** [August 5, 2019, 5:16pm UTC](https://forum.ghost.org/t/set-alt-tag-for-img-if-there-is-figure-caption/6753/3 "2019-08-05T17:16:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kevin/32/32_2.png) [@Kevin](https://forum.ghost.org/u/Kevin)\
**Post date:** [August 5, 2019, 5:21pm UTC](https://forum.ghost.org/t/set-alt-tag-for-img-if-there-is-figure-caption/6753/4 "2019-08-05T17:21:05Z")

</div>

> [@willston](#):
>
> 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 🙂 UI for editing alt text in image cards was added to the editor in Ghost 2.26.0.

> **[Custom image alt tags](https://ghost.org/changelog/image-alt-text-support/)**
>
> We just shipped custom image alt tag support in the Ghost editor. This is one of
> our most requested features – and great news for accessibility and search engine
> optimisation for your Ghost publication.
> 
> Previously, you'd need to use a Markdown card...

---

<div class="post-metadata">

**Author:** ![willston](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/willston/32/3836_2.png) [@willston](https://forum.ghost.org/u/willston)\
**Post date:** [August 5, 2019, 5:21pm UTC](https://forum.ghost.org/t/set-alt-tag-for-img-if-there-is-figure-caption/6753/5 "2019-08-05T17:21:48Z")

</div>

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