Running filters during upload
Hello,
I wonder if it's possible to run a filter and/or custom filter when defining sizes? Apologies if I have missed this in the documentation.
'image-article_small' => array(
'show_in_ui' => false,
'resize' => array(640, 350, 'center'),
'name' => 'Image article small',
),
Something like
'image-article_small' => array(
'show_in_ui' => false,
'resize' => array(640, 350, 'center'),
'webp' => true, // Uses the same towebp filter that comes with timber
'filters' => array('my_custom_filter '), // Uses a custom filter added to twig
'name' => 'Image article small',
),
No worries if this doesn't exist, as towebp does of course crunch the images upload first visit, and so should a custom filter. Just trying to achieve best possible performance.
Hey @parkerwebteam, sorry I didn’t respond earlier.
What would your my_custom_filter do? Can you make an example? If the idea is to add support for WebP conversion, I should probably add that directly.
We’ll need this in the future anyway, I’ll add it to my todo list.
Hello @gchtr
WebP generation would be great - in this instance we setup "blur" filter which created a very small image blurred for the Image Blur Up technique, and did TimberImage | resize | blur which resulted in some very heavy load on the server.
With it already being generated on upload this would just be a disk read.
Check out the latest 1.0.0 release, which comes with WebP support, see:
- https://github.com/mindkomm/timmy/blob/1.x/docs/image-configuration.md#webp
- https://github.com/mindkomm/timmy/blob/1.x/docs/picture.md
To add a custom filter, it would probably be best if you extend Timmy’s image class with your own filter functionality and then use the v1 API to call your function.