Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Is it possible to integrate image.nvim with obsidian.nvim?#294

Demianeen started this conversation inIdeas
Discussion options

I recently found this awesome plugin! But I found myself unable to view the images in it. The solution that I found was aimage.nvim plugin, but from what I see obsidian ignores all path to the image and just uses image name. Is it possible to somehow integrate them?(or any other plugin with such functionality)

You must be logged in to vote

Replies: 3 comments 4 replies

Comment options

Hey@Demianeen this is not on our roadmap, but if someone can find a clean way to integration it then I'd be happy to accept a PR!

You must be logged in to vote
0 replies
Comment options

The solution I have for this is to have all of my images in an assets/images folder which is defined both in Obsidian and obsidian.nvim and then in the image.nvim setup have something like this

markdown= {enabled=true,filetypes= {"markdown"},resolve_image_path=function(document_path,image_path,fallback)image_path="Path/to/vault"..image_pathreturnfallback(document_path,image_path)end,    },
You must be logged in to vote
5 replies
@fvvnky
Comment options

can you demonstrate how it works? Ive been looking for similar functionality!

@maxdulay
Comment options

obsidianimages.mp4
@monkeyxite
Comment options

Nice solution, and how do you get the image_path with multi-workspace? Suppose need get the para from obsidian.nvim in someway?@maxdulay

@maxdulay
Comment options

If you do a:help obsidian.Workspace you'll probably find what you're looking for. I personally don't use workspaces.

@ficd0
Comment options

The issue I see with your solution is that it will return an Obsidian-formatted path for any image inside a markdown document it encounters, even if the markdown file isn't inside your vault & the image path is just a regular relative path.

Comment options

The following solution will work whether you open the file directly, such asnvim /path/to/vault/note.md, or if you are like me, and open Neovim in some other directory (usually$HOME in my case), and then useObsidianQuickSwitch to open notes. It willalso work in normal Markdown files anywhere else on your system.

-- inside 'lua/plugins/image.lua'localfunctionresolver(document_path,image_path,fallback)localvault_dir="/path/to/your/vault"-- Check if the document is inside the vaultifdocument_path:find(vault_dir,1,true)then-- If so, return formatted path to imagereturnvault_dir.."/"..image_pathend-- fallback to default since not in vaultreturnfallback(document_path,image_path)endreturn {  {"3rd/image.nvim",opts= {integrations= {markdown= {resolve_image_path=resolver,        },      },    },  },}
You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Ideas
Labels
None yet
6 participants
@Demianeen@monkeyxite@epwalsh@ficd0@fvvnky@maxdulay

[8]ページ先頭

©2009-2025 Movatter.jp