Embedded image links do not work with []() syntax if there is a space in the file name

Steps to reproduce

I have downloaded and installed Obsidian 0.12.19. I do not have any installed plugins.

The first step I did was try to import markdown export from Joplin, when I noticed issues. To recreate this, I started with a new vault and hand created a file to demonstrate the problem.

Expected result

Based on the documentation at https://help.obsidian.md/How+to/Embed+files I would expect that ![My Image](my image.jpg) would embed an image in the page.

To recreate:

  1. Download an image to test, such as https://www.si.edu/object/banded-iron:nmnhmineralsciences_1369368 (CC0)
  2. Create a copy of the image with a space in the file name
  3. Create a file with the following syntax:
## Example 1 - without spaces
Here is an example of embedding the image without spaces: 

![[NMNH-2007-15229_BandedIron-000002.jpg]]

## Example 2 - without spaces, using the `[]()` syntax 
![NMNH-2007-15229_BandedIron-000002.jpg](NMNH-2007-15229_BandedIron-000002.jpg)

## Exam![Screen Shot 2021-11-28 at 2.12.03 PM|432x500, 100%](upload://tleNm3wmH760OQk3HD7ObXi7XoY.jpeg)
ple 3 - with spaces 
![[NMNH 2007-15229_BandedIron-000002.jpg]]

## Example 4 - with spaces, using the `[]()` syntax 
![NMNH 2007-15229_BandedIron-000002.jpg](NMNH 2007-15229_BandedIron-000002.jpg)

Actual result

For example 4, the image does not display correctly.

Environment

  • Operating system: macOS Monterey
  • Obsidian version: 0.12.19

Additional information

I’ve attached a screenshot of what Obsidian shows in preview


I’ve attached the actual markdown file that I created in Obsidian, and the image file I used. It will not let me upload a duplicate of the “NMNH” image with a space in it, because the shasum is identicial to the first.To recreate against the Image File Spaces Test.md file you will need to duplicate it and create a copy with the name NMNH 2007-15229_BandedIron-000002.jpg

Image File Spaces Test.md (975 Bytes)
NMNH-2007-15229_BandedIron-000002

Thanks for taking a look.

The help file contains this:

If there are spaces in the url, they can be escaped by either using %20 as a space, such as:

[Export options](Pasted%20image)

will clarify the docs.

Thank you both for your response. I had to go digging to find what pop referred to, as I was using the online documentation rather than the in-tool documentation.

A question - if, as the developer notes say, the [[image.jpg]] is syntactic sugar for tje []() does it make sense for the behavior to only be an outlier in this case?

Said another way, the behavior between [[]] and []() is consistent if the filename does not have spaces; but inconsistent if there is a space. If [[]] is just a shortcut to the long form [](), shouldn’t it handle spaces in filenames for both cases?

Thanks

Actually, any Commonmark-compliant implementation should allow spaces in destination part if it is enclosed in pointy brackets:

[link](<file name>)

See https://spec.commonmark.org/0.30/#example-488.

Hi saf-dmitry. It works with the format, with spaces.

At this point, for me, it’s just a question of whether or not the the behavior of [[]] and []() should be the same if there are spaces in the filename. I would think yes, based on the developer notes, but I may be misunderstanding something.

Again, I will clarify the documentation. The format is [page name](page%20name.md) or [[page name]]

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