Skip to content

Commit

Permalink
fix: add warning message when base64 string is too large
Browse files Browse the repository at this point in the history
  • Loading branch information
HakonHarnes committed Mar 11, 2024
1 parent 568f0d9 commit 73f2ea3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lua/img-clip/paste.lua
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ M.embed_image_as_base64 = function(file_path, opts)
end

-- check if base64 string is too long (max_base64_size is in KB)
if string.len(base64) > config.get_opt("max_base64_size", opts) * 1024 then
local base64_size_kb = (string.len(base64) * 6) / (8 * 1024)
local max_size_kb = config.get_opt("max_base64_size", opts)
if base64_size_kb > max_size_kb then
util.warn("Base64 string is too large (" .. base64_size_kb .. " KB). Max allowed size is " .. max_size_kb .. " KB.")
return false
end

Expand Down

0 comments on commit 73f2ea3

Please sign in to comment.