Markdown images: file location

A recently introduced feature is the ability to includes images into Markdown and having the corresponding image files imported into the DB. For that, enable in Prefs > Files > Markdown the option Import images to group.

Options for the image asset location

  • If you enter just a folder name (default is asset), the images will be stored in the subgroup with the same name.
    • Advantage: images will stay close to the md file and a relative file path will be used in the md file, say ![MyImage](assets/MyImage.jpg]
    • Disadvantage
      • If the md file gets moved out of that group, the image link will be broken; however, replicants outside of this group will still find the image.
      • Different images with the same filename used by md files in the same group will collide.
  • If you enter a slashed folder name (e.g. /MyMDImages), the images files will be stored on that absolute path in the DB, independent of md file location.
    • The link in the md file will now be an x-devonthink-item link (exception: the md file is also at the root of the DB)
    • Advantages:
      • From anywhere in the DB, the md file will find its image resources.
      • Images are referenced by a unique ID, no name collisions.
  • Disadvantage: Images are not close to the md file relying on, so it’s harder to export them together (i.e. to another DB or to outside DT, including “Export as webpage”). But see this export script by @pete31.

Thanks for this useful tip! We will extend the description of this option in the help too.

I usually start writing md note in Global Inbox before moving to respective DB. So, that makes the md file at the root of the DB. As such, the image that I paste in the md file is not an x-devonthink-item link. It is a image a relative file path ![MyImage](MyMDImages/E1BBCFE7-02A4-4243-B5D1-4E1C7906D72C_1_105_c.jpeg).

In fact, I use tags mostly. So, most of my files are at the root of the DB.

This make the script fails to move the image when I move the md file.

@gg378 any way to overcome this problem?

That’s a good point. The Global Inbox mechanism makes you put items at the root level. @pete31 's script would have to catch this situation and translate the relative path into an x-item link. The script would have to edit your note, to replace the link name.

Started using another app while ago but still have some stuff on DT. Only came across this feature today when looking through settings. Helps to speed up markdown writing.

Curious why using hardcoded folder path location which renders file missing when image is moved, instead of implementing x-devonthink-item as link? By implementing x-devonthink-item would allow image files to be moved and link is stays valid as script by pete31.

File location not introduced on DTTG yet?

There is no file system on iOS, as has been mentioned regularly. So there can’t be a file location.

Your safest bet be would be to put MD documents and the images they use in a group. Referring to the images simply by their complete name. That should work Abriss platforms and makes it easier to work outside of DT(TG): simply export the group as a folder to the file system.

1 Like

I meant location path similar to Mac which is group location. Should have chosen my word properly. Mac can specify group location when pasting image but not DTTG thus asking the question

As for your suggestion, how to group image?

You create a group in DT in which you put the MD document(s) and their related images.

Thought I know, thought there’s something similar to Mac DT of pasting image to a markdown file. Thanks anyway.

No, this is not currently supported in DEVONthink To Go. It may be in a future release.

Jim thanks for the reply. Hopefully this features will be added in future on DTTG.

You’re welcome :slight_smile: