I am trying to find a way I can future-proof links to my personal media files stored (currently) on my NAS storage so that i can reference them/embed them into my notes. This way, if in the future I find myself having to move the media file directory to another service or location I can just update the root path in one place and still have my obsidian vault finding my files.
Things I have tried
I have tried creating a “global variable” (in this example, stored in a file in my vault “+GlobalVars+”):
=[[+GlobalVars+]].media_root
I’m able to successfully access and append this to create the file path to a file, for example: =[[+GlobalVars+]].media_root/2016-03/2016-03-01/100.JPG
However, what I’m trying to do in order to embed the file doesn’t work but also is very clunky to do long-term. Does anyone have a better way of achieving this? Below is what I’ve been trying with:
[[=[[+GlobalVars+]].media_root + "/2016-03/2016-03-01/100.JPG"]]
Can anyone help me get to the bottom of this problem? Your help would be very much appreciated! I remember seeing something once that some javascript could be run at the start of Obisidian startup and I’m wondering if is could be somehow to generate the whole section in parentheses in a function?
Do however be aware that embedding is a little clunky in any solution.
If you’re only using reading view, and not live preview, you could also consider using Templater user functions, for a slightly leaner function call, like: