Skip to content

Commit

Permalink
docs: provide docs for paste_image function
Browse files Browse the repository at this point in the history
  • Loading branch information
HakonHarnes committed Feb 29, 2024
1 parent 8389b69 commit 3a41089
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lua/img-clip/paste.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,27 @@ local M = {}
---@param input? string file path or url
---@return boolean
M.paste_image = function(opts, input)
-- check if input (file path or url) is provided
if input then
input = util.sanitize_input(input)

if util.is_image_url(input) then
return M.paste_image_from_url(input, opts)
elseif util.is_image_path(input) then
return M.paste_image_from_path(input, opts)
else
util.warn("Input is not an image.")
return false
end

util.warn("Input is not an image.")
return false
end

-- if no input is provided, check clipboard content
if clipboard.content_is_image() then
return M.paste_image_from_clipboard(opts)
end

-- clipboard content as text
-- if clipboard does not contain an image, then get the
-- clipboard content as text and check attempt to paste it
local clipboard_content = clipboard.get_content()
if clipboard_content then
return M.paste_image(opts, clipboard_content)
Expand Down

0 comments on commit 3a41089

Please sign in to comment.