diff --git a/CHANGELOG.md b/CHANGELOG.md index f02bd0a3c..35d727e04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add indicator to entries that don't exist yet in `:ObsidianDailies` picker list. +### Fixed + +- Fixed `img_text_func` example in README. + ## [v3.7.2](https://github.com/epwalsh/obsidian.nvim/releases/tag/v3.7.2) - 2024-03-12 ### Changed diff --git a/README.md b/README.md index f3a3d23d7..010007b64 100644 --- a/README.md +++ b/README.md @@ -497,17 +497,8 @@ This is a complete list of all of the options that can be passed to `require("ob ---@param path obsidian.Path the absolute path to the image file ---@return string img_text_func = function(client, path) - local link_path - local vault_relative_path = client:vault_relative_path(path) - if vault_relative_path ~= nil then - -- Use relative path if the image is saved in the vault dir. - link_path = vault_relative_path - else - -- Otherwise use the absolute path. - link_path = tostring(path) - end - local display_name = vim.fs.basename(link_path) - return string.format("![%s](%s)", display_name, link_path) + path = client:vault_relative_path(path) or path + return string.format("![%s](%s)", path.name, path) end, }, } diff --git a/lua/obsidian/config.lua b/lua/obsidian/config.lua index a6b9bd349..69fa4bf59 100644 --- a/lua/obsidian/config.lua +++ b/lua/obsidian/config.lua @@ -447,18 +447,8 @@ config.AttachmentsOpts.default = function() ---@param path obsidian.Path the absolute path to the image file ---@return string img_text_func = function(client, path) - ---@type string - local link_path - local vault_relative_path = client:vault_relative_path(path) - if vault_relative_path ~= nil then - -- Use relative path if the image is saved in the vault dir. - link_path = tostring(vault_relative_path) - else - -- Otherwise use the absolute path. - link_path = tostring(path) - end - local display_name = vim.fs.basename(link_path) - return string.format("![%s](%s)", display_name, link_path) + path = client:vault_relative_path(path) or path + return string.format("![%s](%s)", path.name, path) end, confirm_img_paste = true, }