Closed rootwork closed 2 years ago
I think you make a good case and I would like us to align on best practices in the industry. Although I would have to personally go to all of my blog posts (since I use this theme) and make the change, I'm glad to do so. But other than a practical recommendation, what is your suggestion here? Is this in need of code or just documentation?
The code piece is that the JS is grabbing the content of the alt
attribute to populate the captions, so that would have to change to grabbing title
instead. I can pull that part out from the original version of the PR and create a new PR if you agree.
Do you want to include some sort of script to auto-duplicate alt
s to empty title
s, or is that too much?
cc @onweru
@rootwork, you make a good point. I noticed the change when I reverted but wasn't sure exactly why you did it. Umh, I would suggest that we proceed as follows.
Option 1 is of course the ideal, because it follows the industry spec. However, not everyone is aware. I reckon most people don't even add a title attribute in their markdown.
This approach would be backwards compatible.
For the actual implementation, the alt would be the default and the title
would be used only where it's defined
let caption = image.title.trim().length ? image.title : image.alt;
I think that makes sense, yes!
Do you all want any documentation updates showing this? If so I can do a doc-only PR.
@rootwork, please go ahead. Thank you.
(Omitting issue template since this is more of a feature request than a bug report.)
Unless I'm mistaken, this change to #206 reverted to using the
alt
attribute in images to populate captions, rather thantitle
, which is what I'd originally proposed in that PR (mentioned in item 3). Don't get me wrong, I'm really excited you accepted what I know was an enormous PR! And of course it's your decision whether to continue usingalt
rather thantitle
for captions, but I want to make the case for why I think it should be the latter.Just to be sure we're on the same page, an image in Markdown defines its attributes this way:
On using captions, WebAIM says it succinctly:
(Emphasis mine.)
Other useful summaries making this same argument:
So alt text isn't really intended to be the same as a caption. And conversely, even if you don't want to display a caption, you should provide alt text unless it's a purely decorative image.
Summary
Deriving captions from
title
rather thanalt
:Drawbacks
The one obvious downside is that sites that had been using
alt
s for captions until now would suddenly have empty captions if you switched to basing it ontitle
. I'd be up for coming up with a regex script to duplicatealt
intotitle
wheretitle
doesn't already exist, if that would help assuage that concern.I suppose it's also a bit more work to type
rather than
but I think that's outweighed by the positives.