`alt` tag section ignored for local image embeds

Steps to reproduce

Make a document with ![Alt text goes here](test.jpg) in it, and include a test.jpg in the same folder.

Expected result

The following rendered HTML:

<div class="markdown-preview-section">
    <div class="internal-embed is-loaded" src="test.jpg">
        <img alt="Alt text goes here" src="app://local/C:%5Csomevault%5Ctest.jpg">
    </div>
</div>

Actual result

The following rendered HTML:

<div class="markdown-preview-section">
    <p></p>
    <div class="internal-embed is-loaded" src="test.jpg">
        <img alt="test.jpg" src="app://local/C:%5Csomevault%5Ctest.jpg">
    </div>
    <p></p>
</div>

Note that the alt text appears nowhere in the output, and the alt attribute on the img is just the name of the file. Notably, the [alt text] works fine for embeds to externally linked images.

Environment

  • Operating system: Windows 10 Pro Build 18363
  • Obsidian version: v0.8.2

Additional information

I’m trying to add css styles to embedded local images, using markdown syntax, utilizing alt text like this:

![alt text goes here -customstyle](thefile.jpg)

And CSS3 substring selectors like so:

img[alt$="-customstyle"] { ... }

If there’s an easier way to add css styles to individual images without resorting to using raw HTML, please let me know.

1 Like

A post was merged into an existing topic: Image alt text not shown on internal embedded images, only on some external embedded