image.nvim icon indicating copy to clipboard operation
image.nvim copied to clipboard

Non-png files always miss the cache

Open b0o opened this issue 1 year ago • 1 comments

Because a random ID is used in the converted filename for non-PNG images, the cached converted files are never used, and the conversion happens every time the same image is loaded:

https://github.com/3rd/image.nvim/blob/5f8fceca2d1be96a45b81de21c2f98bf6084fb34/lua/image/image.lua#L303-L320

Replacing the random ID with a hash based on the original filepath would solve this, but I'm unsure whether that would have unintended consequences?

local id = opts.id or utils.hash.sha256(absolute_original_path)

b0o avatar Nov 25 '24 12:11 b0o

Hey, I don't think it would break anything, will check!

3rd avatar Dec 05 '24 00:12 3rd