HakonHarnes / img-clip.nvim

Effortlessly embed images into any markup language, like LaTeX, Markdown or Typst
MIT License
443 stars 7 forks source link

Base64 config is not working? #47

Closed LintaoAmons closed 5 months ago

LintaoAmons commented 6 months ago
    {
        "HakonHarnes/img-clip.nvim",
        event = "BufEnter",
        opts = {
            default = {
                dir_path = "static", -- directory path to save images to, can be relative (cwd or current file) or absolute
                file_name = "%Y-%m-%d-%H-%M-%S", -- file name format (see lua.org/pil/22.1.html)
                url_encode_path = false, -- encode spaces and special characters in file path
                use_absolute_path = false, -- expands dir_path to an absolute path
                relative_to_current_file = false, -- make dir_path relative to current file rather than the cwd
                relative_template_path = true, -- make file path in the template relative to current file rather than the cwd
                prompt_for_file_name = true, -- ask user for file name before saving, leave empty to use default
                show_dir_path_in_prompt = false, -- show dir_path in prompt when prompting for file name
                use_cursor_in_template = true, -- jump to cursor position in template after pasting
                insert_mode_after_paste = true, -- enter insert mode after pasting the markup code
                embed_image_as_base64 = true, -- paste image as base64 string instead of saving to file
                max_base64_size = 10, -- max size of base64 string in KB
                template = "$FILE_PATH", -- default template

                drag_and_drop = {
                    enabled = true, -- enable drag and drop mode
                    insert_mode = false, -- enable drag and drop in insert mode
                    copy_images = false, -- copy images instead of using the original file
                    download_images = true, -- download images and save them to dir_path instead of using the URL
                },
            },
        },
    }

Here is my config, the changed dir_path is working, but the embed_image_as_base64 = true seems not working. Still saved as file instead of base64 data

LintaoAmons commented 6 months ago

Okie, seems like the file is too large. Is it possible to add a hint when fallback to save as an image file?

HakonHarnes commented 5 months ago

Thanks for reporting. Should be fixed now!