Adding caption to images

Use case or problem

As far as I know, there is currently no “official” way to add a caption to an image.

Proposed solution

I would suggest, that an image with nonempty alt text, occurring by itself in a paragraph, will be rendered as a figure with a caption. The image’s alt text will be used as the caption. Inline Markdown in the alt text should be interpreted.

That means that following Markdown snippet

![This is the caption](image.png)

or

![[image.png|This is the caption]]

will be rendered as something like

<figure>
    <img src="path/to/image.png" />
    <figcaption>This is the caption</figcaption>
</figure>

This is the way pandoc with the implicit_figures extension handles figure captions in Markdown documents.

Concerning implementation details I would suggest to make this behavior optional as an extension.

Current workaround

38 Likes

There is a Discordian theme which can render the image caption.

I agree that it would be great if this feature can be implmented in the core if that’s what you’re asking.

1 Like

@obsidian337 Thank you for the hint!

I already use a very similar workaround (see my workaround link above). The biggest disadvantage of this approach for me, however, is that inline Markdown in the alt text will not be interpreted, so you can not use e.g. inline math in caption text.

1 Like

This would be a really nice feature.
I use Obsidian to study and one of my professors uses a lot of diagrams, would help me so much to be able to caption those

Seconded, I too would like the alt text to be displayed beneath the image.

1 Like

+1 for this feature request.

2 Likes

Take my +1

+1 to this too!

Annoying things like this make me want to go back to Notion

2 Likes

I made a plugin to add image captions: GitHub - bicarlsen/obsidian_image_caption: Add captions to images in Obsidian..

If you try it out I would love your feedback.

3 Likes

I’ve been looking for something like this, thanks. I am getting some ‘failed to load’ errors at times though.

Glad you’ve been finding it useful. If any issues come please raise them on the GitHub page so I can continue to improve it:

Issues · bicarlsen/obsidian_image_caption · GitHub.

Hy @bicarlsen, thanks for making such a wonderful plugin. Before your plugin my work around was to use a snippet. But this made it quite simple.

I have two requests,

  1. Add an option to number the figures in decimals, currently we can only number them from 1, 2, … . and it would be much helpful we can number them as 1.1, 1.2, … 2.1, 2.2,…3.1 …
  2. Also make a plugin (or add functionality in this one) for table captions, I searched a lot and adding table captions are cumbersome. A simple plugin, as this one, will help a lot.

Thanks.

Thanks for the feedback @Learner1. Could you open these as an Issue on the GitHub page so it is easier foor me to track and discuss.

I also miss this function, but I miss it for all the embeds. I would also like to be able to attach a caption to for instance a PDF or a YouTube video.

+1 from me

+1. This will be a nice feature to have. It enables writing of many formal documents other than personal notes.

GitHub - alangrainger/obsidian-image-captions at obsidian-iceberg

3 Likes

Yessss! I never got “Obsidian Caption” plugin to work, but this “Obsidian Captions” finally does it for me, thank you

3 Likes

How would I center the caption if the images were centered?

They’re centered by default. You can make any changes you want via CSS.