diff --git a/lua/img-clip/paste.lua b/lua/img-clip/paste.lua index 21e4863..d66449c 100644 --- a/lua/img-clip/paste.lua +++ b/lua/img-clip/paste.lua @@ -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