Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alt text images #48

Merged
merged 7 commits into from
Aug 21, 2024
Merged

Alt text images #48

merged 7 commits into from
Aug 21, 2024

Conversation

AdrianDAlessandro
Copy link
Contributor

@AdrianDAlessandro AdrianDAlessandro commented Aug 19, 2024

This PR enables us to use {: .no-caption } as an attribute list after defining images for when we do not want there to be a caption.

I will add the following to the README after #41 is merged:

Images are converted to figures automatically using the MkDocs Caption extension. This extension enables putting captions on tables and lists as well as images, however the most basic behaviour uses the image's Alt Text field to populate the figure caption.

For Example:

![figure caption](img.jpg)

Will be converted to:

<p>
<figure id=_figure-1>
    <img alt="figure caption" src="img.jpg" />
    <figcaption>Figure 1: figure caption</figcaption>
</figure>
</p>

Which will render as a centred image with the caption "Figure 1: figure caption".

If you do not want the image to have a caption, you can label it as a no-caption class using an Attribute List. Reminder, it is important to include Alt Text for accessibility reasons.

![figure caption](img.jpg) {: .no-caption }

You can then add to the attribute list to further specify the style. A useful one is for centering images:

![figure caption](img.jpg) {: .no-caption style="display:block;margin:auto;"}

More information on image style options can be found in the Mozilla Documentation.

Close #46

@dc2917
Copy link
Contributor

dc2917 commented Aug 20, 2024

This looks good to me, and does what we want it to.

As a sort-of aside:

Reminder, it is important to include Alt Text for accessibility.

Would we therefore not want it to do something like:

<p>
<figure id=_figure-1>
    <img src="img.jpg" alt=figure caption/>
    <figcaption>Figure 1: figure caption</figcaption>
</figure>
</p>

i.e. populate the alt attribute of the img tag as well? I'd have thought that if the caption is just text on the page then a screen reader would pick it up, but I had a quick google and a read of this article, where someone has tested different screen readers, browsers and combinations of alt text and caption presence. It seems that in many cases, if the alt attribute is empty, the screen reader just ignores the image, including the caption 😕

@SaranjeetKaur
Copy link
Contributor

SaranjeetKaur commented Aug 20, 2024

Thanks @AdrianDAlessandro! I feel it is important to include alt-text on images. Do you think we should link a alt-text guide for reference on the README?

As Dan mentioned, I would also prefer to populate the alt attribute.

@AdrianDAlessandro
Copy link
Contributor Author

Thanks @dc2917 and @SaranjeetKaur

I've checked the mkdocs-caption plugin and it does maintain the alt text (see source code), unlike how their documentation suggests (which is where I pulled that lump of html from). So I'll adjust that accordingly for the README.

Copy link
Collaborator

@dalonsoa dalonsoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

README.md Outdated
</p>
```

Which will render as a centred image with the caption "Figure 1: figure caption".
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe mention that it also becomes the actual Alt Text, in addition to the caption, important for screen readers, as mentioned?

@AdrianDAlessandro AdrianDAlessandro merged commit 3cae2ae into main Aug 21, 2024
3 checks passed
@AdrianDAlessandro AdrianDAlessandro deleted the alt-text-images branch August 21, 2024 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow for alternative text in non-figure images
4 participants