F
Filament15mo ago
daar

Resize image in SpatieMediaLibraryFileUpload

Hello, I find Spatie's package excellent, especially for defining conversions to resize uploaded images. However, I'm wondering if there's a way to convert the original file before it gets placed on the server, thus skipping the conversions. The issue is that the original file remains publicly accessible, and I'd like to prevent that. Regards, Darius
7 Replies
krekas
krekas15mo ago
have you checked media library docs?
daar
daarOP15mo ago
I did, did I overlook anything? As mentioned, the conversions are clearly specified in the docs. But these create a subfolder called conversions with the originally uploaded image file in the root. I would not want the root image to be created, but rather only the conversions.
krekas
krekas15mo ago
doesn't seem that's posible
daar
daarOP15mo ago
I was hoping for some sort of a beforeSave method or perhaps via an observer Does FileUpload allow this?
krekas
krekas15mo ago
if manually then you could delete file
SLy
SLy15mo ago
Not optimal, but you can a write model trait that cleans the root files on save.
krekas
krekas15mo ago
observer in the model one way

Did you find this page helpful?