You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The alt text of an image is a description of the contents which can stand in for the image itself in case the image didn't load or the person can't physically see the image. The title, meanwhile, is a caption which can add more context to the image for a user who can see it.
MDN says "the title attrbiute is not an acceptable substitute for the alt attribute." They are for different things, and images should always have at least an alt, but authors may also choose to have a title which in most cases probably needs different content.
Currently, the text from a markdown image is placed both in the generated image tag as the alt text and ALSO as the figcaption, where it's displayed to all users. It looks like it's possible to pass a different string for the alt vs title in vanilla Hugo by including a string after the image src:
![Alt text here](/images/image.jpg"Title here")
Unfortunately, the figure constructed by the gallery doesn't do anything with this second string, so it's just ignored when it's passed.
I propose that this second string is captured and used for the figcaption if it's available. Ideally, the alt text used in the Markdown between square brackets would only ever be used as alt text (not shown to users as a caption), since they are different strings and not interchangeable. However, I understand that disabling that could be a disruptive for longtime users of the theme. So at the least, it should be possible to override the alt text conflation and not display a figcaption for a given image. You could do this by allowing an empty title:
![Alt text here](/images/image.jpg"")<!-- Alt text with no figcaption -->
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The
alt
text of an image is a description of the contents which can stand in for the image itself in case the image didn't load or the person can't physically see the image. Thetitle
, meanwhile, is a caption which can add more context to the image for a user who can see it.MDN says "the
title
attrbiute is not an acceptable substitute for thealt
attribute." They are for different things, and images should always have at least analt
, but authors may also choose to have atitle
which in most cases probably needs different content.Currently, the text from a markdown image is placed both in the generated image tag as the
alt
text and ALSO as thefigcaption
, where it's displayed to all users. It looks like it's possible to pass a different string for thealt
vstitle
in vanilla Hugo by including a string after the imagesrc
:Unfortunately, the
figure
constructed by the gallery doesn't do anything with this second string, so it's just ignored when it's passed.I propose that this second string is captured and used for the
figcaption
if it's available. Ideally, thealt
text used in the Markdown between square brackets would only ever be used asalt
text (not shown to users as a caption), since they are different strings and not interchangeable. However, I understand that disabling that could be a disruptive for longtime users of the theme. So at the least, it should be possible to override thealt
text conflation and not display afigcaption
for a given image. You could do this by allowing an empty title:Beta Was this translation helpful? Give feedback.
All reactions