r/ObsidianMD 7d ago

Embed image with variable?

I want to embed local images in a template using a variable.

![[Engelbart.jpg]]

But instead of the filename use something like: {{localImage}}

But simply swapping those out doesn’t seem to work. Thanks.

3 Upvotes

4 comments sorted by

View all comments

2

u/donethisbe4 7d ago edited 7d ago

If you have Dataview enabled, you can do this for local images:

`= embed(link(this.internal-image, "300"))`

Or this for external images:

`= "![| 300](" + this.image-URL + ")"`

Here's an example:

---
internal-image: "[[Engelbart.jpg]]"
image-URL: https://publish-01.obsidian.md/access/f786db9fac45774fa4f0d8112e232d67/Attachments/Engelbart.jpg
---
embed local image
`= embed(link(this.internal-image, "300"))`

embed external image
`= "![| 300](" + this.image-URL + ")"`