# Markdown and store image

**URL:** https://discourse.devontechnologies.com/t/markdown-and-store-image/67291
**Category:** DEVONthink
**Created:** [October 19, 2021, 1:00pm UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291 "2021-10-19T13:00:46Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![gg378](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/g/b9e5f3/32.png) [@gg378](https://discourse.devontechnologies.com/u/gg378)
#### Post date: [March 13, 2022, 10:31pm UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/21 "2022-03-13T22:31:12Z")

</div>

> [@chrillek](#):
>
> That is apparently the perception of many people. At least here – I haven’t seen the same kind of discussion in the context of Draft. In some enviroments, there seems to be a tendency to bend this format to perform something it was not meant to. Like the endless discussions about images: There are tons of formats that can handle embedded images just fine. MD is _not_ one of them.

Good points. That made me realize that I’m probably not really expressing well what I’m after. Indeed I should not tell the md crowd or devs what to do for the sake of just md. As a standalone tool, say the quick and dirty notes you mention, I can take it or leave it. And hence, for outside DT, my go-to quick and dirty note tool is Apple Notes. It could be Draft. You name it.

But once a format is adopted within a larger system, then format choices will go away. Let me try to illustrate that:

Jupyter devs _chose_ md as their rich-text format. Great, especially with embedded LaTeX math, it’s very handy. But my use case to make powerful Jupyter documents for my research makes good (i.e. painlessly easy to use) image usage (and also tables) a must. Other than Mathematica there is no other tool out there that would do the job. So all those “tons of formats that can handle images just fine” become irrelevant. I’m chained to md because of Jupyter.

Now, in DT, the use of md docs is not mandatory, but it is _compelling_. An editable document format is particularly useful in DT when it is

1. indexable
2. viewable within DT (ideally natively, but at least with a preview mechanism)
3. editable within DT (for fast workflow)

(text, rtf, rtfd, formatted notes, md) fullfil all 3, whereas Pages and Word fulfill (1), (2) partly, but not (3). Md is in my view the best of the first group, and so, for a DT user, it _assumes_ the _de facto_ role of the most capable, most future-proof (cf. rtf) internal document creator/editor/viewer. And that’s why many people _clamour_ for certain features in it. At that point, the history and philosophy behind it take a back seat. People notice that it’s a cool format, and _so close_ to doing what they want or need. And then they notice that in mmd, a lot of features do eventually show up, so it’s not that devs are very principled either. That at least partially excuses why people suggest features.

The introduction of image assets in DT md, either by dragging a file in or by pasting an image, was a game changer to me. I still would not mind at all the ability to scale the image, but I understand that that’s beyond DT, without breaking md compatibility (unless they spearhead another mmd flavour).

And I was then particular excited to find that I can collect all my image assets in one, x-item-referenced, location, which makes for my use case (and only mine!) the use entirely foolproof. I hindsight, I should have just pointed out the ability to put a slash in front of the asset folder name to make the location absolute. I should have abstained from remarking on the (factual) non-universality of the group-based location, which has its own advantages, as was pointed out.

---

<div class="post-metadata">

### Author: ![chrillek](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/chrillek/32/29340_2.png) [@chrillek](https://discourse.devontechnologies.com/u/chrillek)
#### Post date: [March 14, 2022, 8:02am UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/22 "2022-03-14T08:02:16Z")

</div>

Thank you very much for this thorough assessment. Although I’m not happy with it, it describes the situation quite accurately.

Also, I learned a lot about Jupyter notebooks –thanks for that, too!

As to „scalable“ images: why not use CSS for that? But you’ve opened a new thread for that,  
so I’ll head over there.

---

<div class="post-metadata">

### Author: ![TonyLim](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@TonyLim](https://discourse.devontechnologies.com/u/TonyLim)
#### Post date: [July 9, 2022, 1:06am UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/23 "2022-07-09T01:06:51Z")

</div>

When I move the markdown document, I got this error in the log:

> “Smart Rule: Couldn’t find the moved record’s old "Assets" group”

The image in the markdown document is not moved. The markdown document now has a broken link, image not displayed.

Under Preferences `Files > Markdown`, I have Set the location to `/MyMDImages`

In the script, I have also change the **property** theImageDestinationLocation : “/MyMDImages”

Is there anything else I need to change?

---

<div class="post-metadata">

### Author: ![TonyLim](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@TonyLim](https://discourse.devontechnologies.com/u/TonyLim)
#### Post date: [July 9, 2022, 1:30am UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/24 "2022-07-09T01:30:43Z")

</div>

Just an update of my observation. It seems the problem is that the image is not an x-devonthink-item link due to my md file is at the root of the DB.

More details here:

> [@Markdown images: file location](https://discourse.devontechnologies.com/t/markdown-images-file-location/70034/3):
>
> 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 overcom…

---

<div class="post-metadata">

### Author: ![gg378](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/g/b9e5f3/32.png) [@gg378](https://discourse.devontechnologies.com/u/gg378)
#### Post date: [July 9, 2022, 10:23pm UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/25 "2022-07-09T22:23:06Z")

</div>

> [@TonyLim](#):
>
> It seems the problem is that the image is not an x-devonthink-item link due to my md file is at the root of the DB.

Indeed. @pete31 pointed that out. I would not have run into this problem as I never put documents at the root level. From @cgrunenberg 's explanation, this effect is hardwired into DT and we cannot influence it.

---

<div class="post-metadata">

### Author: ![TonyLim](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@TonyLim](https://discourse.devontechnologies.com/u/TonyLim)
#### Post date: [July 10, 2022, 12:25am UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/26 "2022-07-10T00:25:49Z")

</div>

I am curious why md file at root level cannot create x-devonthink-item linked image? I have many md files at root level with x-devonthink-item link. I manually import the image. Copy the item link and Paste the item link.

---

<div class="post-metadata">

### Author: ![gg378](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/g/b9e5f3/32.png) [@gg378](https://discourse.devontechnologies.com/u/gg378)
#### Post date: [July 10, 2022, 1:24am UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/27 "2022-07-10T01:24:33Z")

</div>

> [@TonyLim](#):
>
> I am curious why md file at root level cannot create x-devonthink-item linked image?

It is not a question of whether it can be done. It’s a judgement call by the devs when to choose one or the other. As @cgrunenberg explained above:

> Currently the used link depends on the location of the image and the document - if possible a relative link is preferred as that’s more compatible to other apps.

There are advantages to regular paths/links: They can be interpreted straightforwardly by other apps. So for example, if I want to use Typora as an external md-editor, it will not be able to make sense of the x-items. Any technique that relies on x-item links must be understood to only work within DT.

---

<div class="post-metadata">

### Author: ![TonyLim](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@TonyLim](https://discourse.devontechnologies.com/u/TonyLim)
#### Post date: [July 10, 2022, 3:03am UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/28 "2022-07-10T03:03:48Z")

</div>

Ok. It makes sense to make it more portable, more usage for other external app to use relative path.

I thought that has already been covered if you use a name, such as `Asset`, without the `\`. You will get a relative path.

For those who wants x-item, you have to use `\`. That will generate x-item link, except at the root level. So, question is why exclude md file at root level?

---

<div class="post-metadata">

### Author: ![gg378](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/g/b9e5f3/32.png) [@gg378](https://discourse.devontechnologies.com/u/gg378)
#### Post date: [July 10, 2022, 9:31pm UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/29 "2022-07-10T21:31:15Z")

</div>

> [@TonyLim](#):
>
> For those who wants x-item, you have to use `\`. That will generate x-item link, except at the root level. So, question is why exclude md file at root level?

For one, this is a DT design decision, so I can’t really answer authoritatively. Having said that, I think the decision made by DT is not “absolute vs. relative path”, but rather “is the resource in a subfolder or not”. Documents put at the root level are special in the sense that any other document (other than those that are also at the root level) will by definition be in a subfolder (even if by more than one level).

---

<div class="post-metadata">

### Author: ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)
#### Post date: [July 11, 2022, 8:04am UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/30 "2022-07-11T08:04:59Z")

</div>

We might add a preference to choose the desired behaviour if there should be a common need for it.

---

<div class="post-metadata">

### Author: ![TonyLim](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@TonyLim](https://discourse.devontechnologies.com/u/TonyLim)
#### Post date: [July 11, 2022, 2:26pm UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/31 "2022-07-11T14:26:48Z")

</div>

Will appreciate if it can be added as a preference. Thanks.

---

<div class="post-metadata">

### Author: ![TonyLim](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@TonyLim](https://discourse.devontechnologies.com/u/TonyLim)
#### Post date: [July 12, 2022, 8:10am UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/32 "2022-07-12T08:10:07Z")

</div>

> [@pete31](#):
>
> Matching:
> 
> - All
> - Content: `![`
> - Content: `x-devonthink-item://`
> - Kind: Markdown

I just found out that this search condition is not working. The `Content: ![` will find match all resulted all Markdown file. In fact, I find using just `Content: x-devonthink-item://` also does not match the correct Markdown file.

How should we redefine the search condition?

---

<div class="post-metadata">

### Author: ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)
#### Post date: [July 12, 2022, 8:14am UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/33 "2022-07-12T08:14:07Z")

</div>

> [@TonyLim](#):
>
> The `Content: ![` will find match all resulted all Markdown file.

The query is actually invalid as _matches_ (EN) or _stimmt überein mit_ (DE) conditions use the alphanumeric search index.

---

<div class="post-metadata">

### Author: ![TonyLim](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@TonyLim](https://discourse.devontechnologies.com/u/TonyLim)
#### Post date: [July 12, 2022, 9:37am UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/34 "2022-07-12T09:37:41Z")

</div>

What about just simply `Content: x devonthink item`? Somehow, it still cannot find the file.

But this search (x devonthink item) works in Inspector search.

---

<div class="post-metadata">

### Author: ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)
#### Post date: [July 12, 2022, 9:52am UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/35 "2022-07-12T09:52:14Z")

</div>

> [@TonyLim](#):
>
> What about just simply `Content: x devonthink item`? Somehow, it still cannot find the file.

DEVONthink doesn’t index the raw source without enabling the hidden preference `IndexRawMarkdownSource`.

---

<div class="post-metadata">

### Author: ![TonyLim](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@TonyLim](https://discourse.devontechnologies.com/u/TonyLim)
#### Post date: [July 13, 2022, 2:27am UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/36 "2022-07-13T02:27:48Z")

</div>

I have enabled the hidden preference. The search work on all newly created Markdown file after the enabling of the hidden preference. Those old Markdown file created before the enabling seems not indexed. How can I force a re-index for those old Markdown file?

---

<div class="post-metadata">

### Author: ![pete31](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/p/d26b3c/32.png) [@pete31](https://discourse.devontechnologies.com/u/pete31)
#### Post date: [July 13, 2022, 3:01am UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/37 "2022-07-13T03:01:26Z")

</div>

> [@TonyLim](#):
>
> How can I force a re-index for those old Markdown file?

Rebuild the database, see menu `File > Rebuild Database`.

From help:

> **Rebuild Database** : Completely rebuilds the database by exporting all items to a temporary folder in the file system, creating an empty database, and reimporting all items. This removes any structural problems. Depending on the size of your database, this can take from a few seconds to several hours. This option is typically only used in a troubleshooting situation.

---

<div class="post-metadata">

### Author: ![TonyLim](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@TonyLim](https://discourse.devontechnologies.com/u/TonyLim)
#### Post date: [July 14, 2022, 9:15am UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/38 "2022-07-14T09:15:51Z")

</div>

Thanks. It works.

---

<div class="post-metadata">

### Author: ![TonyLim](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/t/5e9695/32.png) [@TonyLim](https://discourse.devontechnologies.com/u/TonyLim)
#### Post date: [September 30, 2022, 12:45am UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/39 "2022-09-30T00:45:48Z")

</div>

Thanks for making this in 3.8.6. Now, all my images, copy&paste, drag&drop, are all in x-item link, even for Markdown file at root level.

For the Import images to group, would it be possible, in future, for us to select which database, which group/folder/level?  
 ![Screenshot 2022-09-30 at 8.41.02 AM](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/3/0/30e82da3a42bd1004c4528254483d5c7364018cf.jpeg)

As the images are all Item Link, it is no longer important that they reside in the same database as the Markdown document. In fact, I have created a separate database just to house all the images, at root level.

---

<div class="post-metadata">

### Author: ![mdisabato](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/mdisabato/32/27700_2.png) [@mdisabato](https://discourse.devontechnologies.com/u/mdisabato)
#### Post date: [December 28, 2022, 8:18pm UTC](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291/40 "2022-12-28T20:18:10Z")

</div>

I support this as well. I have quite a few HTML files in different databases that link to images in a single database. The _only_ reason I am considering Markdown is the inability to edit HTML on DT2G. I would really like a simple mechanism that allows this.

Thank you.

Michael

[Previous page](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291.md?page=1)

[Next page](https://discourse.devontechnologies.com/t/markdown-and-store-image/67291.md?page=3)
