Links to pasted images are relative to the vault root - fails with subfolders
🐛 Describe the bug
The default for attachemnts (images) is "assets/imgs"
Using ObsidianPasteImg adds the image path relative to the vault root correctly. For all obsidian notes in the vault root, this works correctly (the path will be [name](assets/imgs/foo.png))
But if the note is in a subdirectory of the vault root, the imge link is still added relative to the vault root and thus not found (the path will still be [name](assets/imgs/foo.png)) - but at least MarkdownPrevew wil lthen not find it.
Changing it to either [name](/assets/imgs/foo.png) (note the slash before assets, or something like [name](../assets/imgs/foo.png) if the note is in a direct subdir of the vault root makes it work properly.
It would be great if the pasting code could either determine and set the relative path correctly or set an absolute path.
I have already tried to set
-- Specify how to handle attachments.
attachments = {
-- The default folder to place images in via `:ObsidianPasteImg`.
-- If this is a relative path it will be interpreted as relative to the vault root.
-- You can always override this per image by passing a full path to the command instead of just a filename.
img_folder = "/assets/imgs", -- note the slash before assets
},
but to no avail.
Config
any config, just add a note in a subfolder, use ObsidianPasteImg and show the note in e.g. markdown-preview
Environment
> nvim-lazy --version
NVIM v0.11.0-dev-1502+g17b46d01e2
Build type: Release
LuaJIT 2.1.1734355927
Run "nvim -V1 -v" for more info
> nvim-lazy --headless -c 'lua require("obsidian").info()' -c q
Obsidian.nvim v3.9.0 (ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b)
Status:
• buffer directory: nil
• working directory: /Users/me/vaults/personal
Workspaces:
✓ active workspace: Workspace(name='personal', path='/Users/me/vaults/personal', root='/Users/me/vaults/personal')
✗ inactive workspace: Workspace(name='work', path='/Users/me/vaults/work', root='/Users/me/vaults/work')
Dependencies:
✓ plenary.nvim: 857c5ac632080dba10aae49dba902ce3abf91b35
Integrations:
✓ picker: nil
✓ completion: enabled (nvim-cmp) ✗ refs, ✗ tags, ✗ new
all sources:
Tools:
✓ rg: ripgrep 14.1.1
Environment:
• operating system: Darwin
Config:
• notes_subdir: nil%
most probably, ObsidianRename as in "move" should then be able to deal with this, too, at least unless the relative form is used
See https://github.com/obsidian-nvim/obsidian.nvim/issues/32