-
i hope to make separated directory depends on note. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
If you are asking about having the img_folder be relative to the current note, I would very much like to do this. Anyone know of an easy way? |
Beta Was this translation helpful? Give feedback.
-
Yes to both. You use a note-dependent directory by overriding the image_name_func = function()
---@type obsidian.Client
local client = require("obsidian").get_client()
local note = client:current_note()
if note then
return string.format("%s/", note.id)
else
return string.format("%s-", os.time())
end
end, And if you want the folder to be relative to the current note, you could have image_name_func = function()
---@type obsidian.Client
local client = require("obsidian").get_client()
local note = client:current_note()
if note then
return string.format("%s/imgs/", note.path)
else
return string.format("%s-", os.time())
end
end, In that case you may also want to update attachments = {
-- A function that determines the text to insert in the note when pasting an image.
-- It takes two arguments, the `obsidian.Client` and an `obsidian.Path` to the image file.
-- This is the default implementation.
---@param client obsidian.Client
---@param path obsidian.Path the absolute path to the image file
---@return string
img_text_func = function(client, path)
path = client:vault_relative_path(path) or path
return string.format("![%s](%s)", path.name, path)
end,
}, |
Beta Was this translation helpful? Give feedback.
Yes to both. You use a note-dependent directory by overriding the
image_name_func
option:And if you want the folder to be relative to the current note, you could have
image_name_func
return an absolute path like this: