Open riw opened 2 years ago
I agree this would be a useful feature to have. However, I'm quite stripped for time right now (you can probably tell by the late reply 😉) so I will make absolutely no promises as to when I get to this. Might be days or years, but if you're interested in seeing this soon I'm very happy to accept a PR!
Really interested in this, though I wonder how it could work with multivariant queries. Should imagetools's default be to have image names mirror the queries (favicon_180w_180h.png)? Then if name=custom_name
is passed, apply it. I get hung up on how we could tackle multivariant queries for things such as w=1;2;3;4&quality=25;50;100
edit Jan. 8, 2023: I believe the name
param should be the base of the new url. If there are no multivariant queries apart from format, the name will be applied directly (e.g. favicon.svg?w=180&h=180&name=apple-touch-icon&png
-> apple-touch-icon.png
).
If there are multivariant queries, the differences should be applied as is done in the core imagetools tests (e.g. favicon.svg?w=180;192&h=180&name=apple-touch-icon&png
-> apple-touch-icon-w_180.png
)
We should omit the hash when applying a name or provide an option to omit the hash altogether.
I'll leave you with a use-case example:
i.e. a file might end up named hero.a7929d7f.avif
, which might be used for OpenGraph/social media. Later, we regenerate the images, and the hash changes, but the post/thread/message is trying to look for hero.a7929d7f.avif
(even though it's now called hero.s12x43ac.avif
). I don't think LinkedIn, Slack, Facebook and likes are scraping for updated meta tags as much, or if at all?
☝️ This happens on https://github.com/klyngeorg/website, which is re-building every day at noon. I'm not sure what to do with it yet, so this feature would be great :)
i would like to use vite imagetools to generate my favicons. i have a singe favion.svg and want to generate all the other files from it. it would be very useful if you could add a directive to rename the file like e.g.
favicon.svg?w=180&h=180&name=apple-touch-icon&png
favicon.svg?w=192&h=192&name=favicon-192&png
favicon.svg?w=512&h=512&name=favicon-512&png