Exchanging Wikilinks with Markdown image links -- Future-proofing our image referencing

I wrote most of what I wanted to write up about this here:

I expect that link to be valid at all times, but I still decided to copy and paste those lines here:

Referencing images and future-proofing them


You can use the Wikilink reference, but it is superior to use markdown links for referencing your images so other apps (like MWeb on iOS) and non-Obsidian or non-Obsidian-Publish programs and web apps can interpret them and make use of them.

I use Wikilinks for internal links and use markdown links for referencing images.
They look like this:
![image](assets/filename_image1.png);
![image](assets/filename_image2.jpeg);
etc.

  • I try to remain true to the filename when naming and referencing images, but usually I remove spaces between strings; a file named File name is such will have images named Filenameissuch_image1, etc.

You can make use of the Paste Image Rename plugin for keeping your image names identical with filenames.
But that will reference images with Wikilinks.

The exchange

What you can do is use regex to exchange those with markdown links.

You can use a plugin (Regex Pipeline or better, Apply Patterns) to exchange links within the file or you can use a text editor like VSCode, Notepad++, Sublime Text, etc. to make changes for your whole vault. (Make a backup first, just in case you make a mistake somewhere.)

In my case (I have an ‘assets’ attachment folder under each of my folders, you may not need that):
Match: !(\[\[)(.*?)([.])(png|jpg|jpeg|bmp|gif)(\]\])
Replace: ![](assets/$2$3$4) or:
Replace: ![]($2$3$4).
If you have spaces between strings in image names, you must add < and >:
Replace: ![](<$2$3$4>).

See also:
https://forum.obsidian.md/t/have-separate-use-markdown-links-options-for-wikilinks-and-image-links/7686/9?u=gino_m



On another sort of future-proofing, see:

2 Likes