How to include an image in a Markdown document?

If I want to include an image in a Markdown document, how do I reference the correct path? Let’s say that I create a Group to collect together all the pieces—both the document and images that it references. The following Markdown code does not work:


![caption](image.png)

```Apparently, the image file is not located in the same directory as the Markdown document itself, even if I put them in the same Group. Now, I [i]can[/i] cheat and look up the path using the Info dialog, and by trial and error, I discovered that I can change the image path to something like ```

![caption](../../pdf/f/image.png)

```and that works. But, come on, I shouldn't have to use trial and error to discover the right path to use. 

Is there an easier way? I'm probably missing something obvious ...


Use the DTPO URL and...

![All Blacks logo](x-devonthink-item://C922725B-DB24-437A-9F71-1EBFA32EE0BA)

Screenshot 2017-10-02 19.05.47.png

In other words, get the DTP link by selecting the document and ‘Copy Link’ or cmd-opt-ctl-c and use it instead of an http or other link.

HTH…

Working as expected here…

Hey Bluefrog, can you clarify what “works as expected”, exactly? Are you using the ordinary file pathname approach that I described, or the Mac-specific “x-devonthink-item” URL?

Just to demonstrate what happens in my enviornment:
t1.pngt2.pngI’d be happy to try different test cases if that would help debug why it fails for me and works for you.

@Brookter, thanks for that. That’s interesting that the link works in that context—I didn’t expect those links to work in this situation, but I tried it and it does indeed. Unfortunately, it doesn’t seem to work for Markdown processors that are not DEVONthink (which is part of the reason I’m using Markdown in the first place), but this may be useful for some cases. Good to know, anyway.

@mhucka, leave off the extension .png and then it should work.

So I tried it, and you’re right, that does work, within DEVONthink. It doesn’t help outside of DEVONthink, but it’s interesting and probably faster to type than to use the item link.

Thank you for mentioning this.

Correct, as the groups don’t exist in the filesystem. This is for editing within DEVONthink (per User requests).

I am using relative links (based on the settings in Typora) for images in markdown.

Unfortunately, they do not render in devonthink, thou it works in e.g. other MD editors I have here.

I am using Indexed Folder in DT3.

What is wrong here?

Md file:

That is what i see in DT3:
image

Folder with Image:

The path to the .png file is relative to your document, but it exists only outside of DEVONthink. To make it work inside DEVONthink, you would need to find the path to the same file inside DEVONthink and update the path used in the image reference, after you’ve imported everything into DEVONthink.

(Maybe this was unclear, but when people were talking about relative paths upthread, it was assumed to be relative paths inside of a DEVONthink group/folder structure.)

Not sure this is my case though, as I am using indexing so files sit in Finder on the Mac. The files do not exist inside DT3. And the links do exists and work well in all other MD editors apart from DT3 … :cry:

I’m trying to be “cheeky”, but perhaps the solution is to use one of “all the other MD editors”? If the image not in DEVONthink and your link doesn’t include the link to the image, then how can it work?

That is the wrong syntax for the link.

If the image is in a subfolder of the folder the Markdown document, it would be subfolder/image.png.

And the md doc must be inside DT? As in your example? Or it is expected to work with indexed md file as well? My use-case is only indexed files as they are processed by some other tools but I am trying to be able to see the result inside DT e.g. while searching for something.

I tried with an a file inside DT as well and corrected the link but still had no luck:

This is what I see in the same file in some other tools:

My files are indexed as indicated by the snall Finder icon to the right of the image name in the group.

Please show the item list with the Markdown document and where the group with the image is.

I was under the impression that your “indexed images.md” is not indexed but lives inside DT. All indexed files have a small finder icon. It seems to me that in your example your md file is indeed not indexed as it lacks the icon. But as I say, I tried this option as well and it did not fix the problem.

The files in question in my example (all located inside one indexed folder):


Image Link:
image
image

I have this problem with DT rendering with all my indexed md files with images so there seems to be some systematic issue not related to this particular file.

Thanks.

The Markdown file being indexed shouldn’t have any bearing on this.

Does it persist after quitting and relaunching?
After rebooting?

Unfortunately this did not help.

What is interesting that DT is recognizing this syntax and renders this properly.
image

Just curious, what his the full path to the folder, which I assume is on your MacOS file system? Or is this a “20201226-Team topologies.assets/” somewhere in DEVONthink?

Edit: and where relative (MacOSX file system and/or DEVONthink) to the file in which this text is located?