F
Filament15mo ago
Wint

How to optimize a uploading image

I'm trying to optimize the image while uploading using spatie/image-optimizer but don't how to do this, can you help me out. - I see we can add manipulations when uploading images but couldn't figure out what string should be passed into. - Or should I using a middleware? how should I using a middleware with file upload? Or which function should I use to hook into the upload process?
2 Replies
Dan Harrin
Dan Harrin15mo ago
you should probably do it in a model observer that queues a job
Wint
Wint14mo ago
Thanks for your idea, I ended up using a event listener as mentioned here: https://spatie.be/docs/laravel-medialibrary/v10/advanced-usage/consuming-events