Insert metadata as a link to a file/folder path

What I’m trying to do

I am trying to insert metadata (which contains the path to a file/folder) as a hyperlink so that in reading mode I can click on the image to go to the specified path in Windows explorer

Things I have tried

I tried to insert a metadata string as a link using the Dataview plugin as an inline DQL, but that just outputs what’s in the metadata (doesn’t turn into a link)

For example:

---
Folder: <file:///C:\Program Files>
---
[![[folder.png]]](`= this.Folder`)

Outputs the following:
image

Try wrapping the file path in a call to link() like so:

(`= link(this.Folder)`)

From the DataView documentation

I tried your version and also based on it I tried to write it in different ways to turn it into a hyperlink. Not sure but it seems like this function applies to files inside the Obsidian file manager, it doesn’t work as a link to a local file in the computer file system, or I’m doing something wrong :thinking:

I think I found a way to use metadata as a hyperlink, but only with text. It seems a bit wonky, but it works as text with a hyperlink. This solution led me to this method.

---
Folder: C:\Program Files
---
`= "[Folder]" + "(<file:///" + this.Folder + ">)"`

Specifically, what I’m trying to do is an image with a hyperlink that comes from metadata.
I tried to do the same with an image, but the Dataview inline query outputs it as text.

Here’s another way, but this time for an image with a hyperlink. This method also seems strange and confusing, but it works. This solution from GitHub led me to this method using a JavaScript inline query.

---
Folder: C:\Program Files
image: "[[folder.png]]"
---
`$= '[<img src="' + app.vault.getResourcePath(dv.current().image) + '"/>]' + '(<file:///' + dv.current().Folder + '>)'`

image

There may be an even simpler way, but overall this looks like a solution to my problem :raised_hands:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.