Would it be possible to use image title instead of alt text for the caption?
It appears you can set the title of an image like so. I'm wondering if there could be an option to allow using the title instead of alt text for the image caption. Could be a nice convenience over putting in HTML for a caption.
Or is there already a good way to set a separate caption that I'm missing?
I’d +1 this feature. It’d be great to be able to use alt text for its intended accessibility virtue and still easily set a separate caption.
I like this too – I propose modifying the image caption feature such that the title is chosen as first priority, then the alt text as fallback. This feels more correct than ignoring the title and just using the alt text
I've deployed a change to make this happen – the title text is chosen as first priority over the alt text when sourcing the image caption
Very cool! Thanks for doing that!
Yes, thank you! Seems to be working great
On my site, I want captions for some images, but not for others. Is there a way to configure Blot to do the following:
- If there is both an alt and a title, use the alt for accessibility and the title as a caption.
- If there is an alt and no title, use the alt for accessibility and do not create a caption.
It's not possible to configure Blot itself this way but if you add the following JavaScript to your template's script.js file, you should get the desired result:
document.querySelectorAll('.caption').forEach(caption => caption.previousElementSibling?.tagName === 'IMG' && !caption.previousElementSibling.title ? caption.style.display = 'none' : null);
Explanation
document.querySelectorAll('.caption'):
Selects all elements with the classcaption..forEach(caption => ...):
Iterates over eachcaptionelement found in the NodeList.caption.previousElementSibling:
Checks the sibling element immediately before thecaption(expected to be theimgtag).?.tagName === 'IMG':
Ensures the previous sibling exists and is animgtag. The optional chaining (?.) prevents errors if thepreviousElementSiblingisnull.!caption.previousElementSibling.title:
Verifies theimgtag has notitleattribute. If thetitleis missing or empty, this condition evaluates totrue.caption.style.display = 'none':
Hides thecaptionby setting its CSSdisplayproperty tonone.
This ensures only captions with corresponding images that lack a title are hidden.
That's perfect, thank you! :)
I realized just now that this won't work on the RSS feed. So I would appreciate a backend solution – though it's possible I'm the only one that needs it :)
Alex
How do you want to apply this technique to an RSS feed?
There is currently an option that reads: "Create a caption from the image’s alt text"
You could add a second option that reads: "Create a caption from the image’s title text (instead of alt, if it exists)"
People who want both can enable both.
People, like me, who only want the title to be used as a caption, would enable only the second option.
How's this?
–Alex
I'll have a think but my gut reaction is that this would add more complexity than is neccessary to the settings panel. Would it not be preferable simply to disable Blot's caption generator and create the caption yourself, e.g. in your markdown file:

Caption goes here
I'll check if I can get this to work, but I think that won't allow me to style the caption appropriately, since I won't know if something is a caption or just the next paragraph.
Alex