I am working on on integrating the Image Optim API (https://imageoptim.com/api) into my Kirby site. This service compresses images for you and returns the new compressed asset.
Thinking the workflow would be that I hook into Kirby and listen for file upload. When a file (image) is uploaded I would send it off, download the new asset, and save it to the page’s files. It would probably be a good idea to keep the original file on hand, but I wouldn’t want to show the original file in the Panel file listing or when loading a page’s files.
I was thinking I could build a custom files method and extend to filter them out, but it says you can’t override the built-in methods.
The only option I have come up with would be to add a period at the beginning of the original file name to convert it to a hidden file. Example after uploading hello.jpg
it would get renamed to .hello.jpg
and a compressed hello.jpg
would be added.
Any thoughts?