FileUpload imageEditor replace instead of adding v1, v2 to the file

Hello, I am uploading images using FileUpload and I have added the imageEditor option and it works great but it automatically adds -v1 -v2 to the filenames created by the editor. I would like to ask if it is possible to replace the existing file instead of creating the new one? Thank you
9 Replies
mohdaftab
mohdaftab4mo ago
Please anyone?
awcodes
awcodes4mo ago
Are you sure you want to do this? If you replace the original then you potentially loose the ability to edit it again. Imagine cropping it too small then if you replace it you won’t be able to fix it since upsizing an image is always a bad result.
mohdaftab
mohdaftab4mo ago
Hello @awcodes I didn't know there was an option to use the original file again. I don't see it, please let me know where do I find it? Thank you so much
awcodes
awcodes4mo ago
The original file name will be available on the file (TemporaryFileUpload) from livewire that is injected into the callback.
mohdaftab
mohdaftab4mo ago
I understand where the file is located but how do I restore it using Filamentphp? I thought it can be somehow restored in Filament admin panel.
awcodes
awcodes4mo ago
What do you mean by restored? That’s kind of the point I was making. If you don’t use the v* naming convention then the original file will get overridden meaning you can’t reference it again for modification.
mohdaftab
mohdaftab4mo ago
I understand, but that is not the case with my project. The client has all the images separately, so if there is a mistake he can reupload the file and crop again if required. otherwise client doesn't know where the original files are located on the server, they can just upload from their own collection again. I did however, add the observer to remove the other files and keep only the ones that are in the database, but I just wanted to make it use the same name instead of adding -v1 -v2 so I don't have to delete them everytime and the image names stay the same for SEO purpose as well.
awcodes
awcodes4mo ago
Why does the client care where the file is stored? The client only cares about modifying the file. There’s also 0 Seo benefit to an image url from what i have seen in my experience. Seo doesn’t care about the image url only that it isn’t render blocking.
mohdaftab
mohdaftab4mo ago
I said this because as you said if the original file is kept on the server it can be used if there is a mistake in cropping. So client is not going to recover it from the tmp folder or any folder on the server unless he has an option in the dashboard panel to restore the original image. This is why I am trying to use the same filename and reupload it if there is a mistake. This is actually an old website which is being redeveloped so the images are already indexed, what we need is to not have new urls and use the same old indexed images for older posts and listings