Why isn't there a way to add a caption to a local image in one of my Obsidian markdown notes?

Things I have tried

What I’m trying to do

Why isn’t there a way to add a caption to a local image in one of my Obsidian markdown notes?

I’ve been using subscript <sup></sup> on the line after the image to act as a caption.

2 Likes

Hi there is actually a way that was shared in the discord by @foreveryone that will use snippets:

Message: Discord

Snippets:

Input in the note:

![[imagename.jpg|left|200]]

<figcaption id="left" style="width:200px">This is a caption</figcaption>


** Note: the width = the width of the image, set through the pipe (for example: `![[image.png|left|400]]`
1 Like

Here is another possible workaround I’m currently using. You can display the image’s alt text as figure caption using the following CSS snippet:

.image-embed[alt]:after {
    content: attr(alt);
    display: block;
    margin: 0.2rem 1rem 1rem 1rem;
    font-size: 90%;
    line-height: 1.4;
    color: var(--text-faint);
}

Here an example:

Please note, however, that inline Markdown syntax in the alt text will be not interpreted.

14 Likes

Please, also see my feature request:

Thanks for the snippet. But even though I activated it as CSS snippet, it does not display the caption.

This is how I did. Am I missing anything? :face_with_monocle:
(tried with theme and with no theme selected)

@mo49

Unfortunately, this seems to work currently only for internal images (images saved inside your vault), referenced using relative path to the image file, e.g.

![Caption](image.png)

or

![[image.png|Caption]]
2 Likes

Oh okay! But it works now. Thank you so much :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.