Skip to content

Commit

Permalink
Fix img_text_func example in README
Browse files Browse the repository at this point in the history
Fixes #491.
  • Loading branch information
epwalsh committed Mar 13, 2024
1 parent 82fa400 commit 9049199
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
Expand Down
14 changes: 2 additions & 12 deletions lua/obsidian/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down

0 comments on commit 9049199

Please sign in to comment.