F
Filament5mo 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
krekas5mo ago
have you checked media library docs?
daar
daar5mo 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
krekas5mo ago
doesn't seem that's posible
daar
daar5mo ago
I was hoping for some sort of a beforeSave method or perhaps via an observer Does FileUpload allow this?
krekas
krekas5mo ago
if manually then you could delete file
SLy
SLy5mo ago
Not optimal, but you can a write model trait that cleans the root files on save.
krekas
krekas5mo ago
observer in the model one way