UploadMany + resize + Thummnail
UploadMany + resize + Thummnail
Hello,
I am using the uploadMany method to upload image files. Sometimes the images may come from a camera and I wish they could be reduced in size. That is, to admit images of 7Mb, but that are loaded with a maximum of 400Kb.
The images are stored in an uploads folder and I would like a copy reduced to 50% to be saved at the same time in uploads / thumb.
I have only been able to find something in a somewhat old comment, March 2017 and the pre-1.6 version of the Editor.
https://datatables.net/forums/discussion/41169/howto-to-resize-thumbnail-on-upload-file-how-to-reach-the-more-easy-example-for-dummies
My question is if any resize method has been implemented, I have looked for it in the Upload.php file, but I can't find anything.
Thanks
Replies
No, there isn't a resize option in Editor, so that thread you point at would be the way to go,
Colin
Thank you. I will follow that path.
Any other contribution is appreciated ...
I have managed to insert the necessary code to generate the thumbnail, but I would like the name of the files not to correspond to the id of the image, but to keep the original name.
I've tried using NAME from Upload.php, but it doesn't work for me.
This is what I have on the server side:
Sorry, previously I had not copied all the code
I think it has to be something like a variable that retrieves the filename, but I don't know how to do it.
The problem with that is, what if user A uploads "Picture 1.jpg" and then user B uploads "Picture 1.jpg". You've got a naming cash and either need to ask the user to rename it, or overwrite the original. Neither is ideal and I'd strongly recommend you don't use this naming scheme.
Perhaps you could prepend the file id to the name? You'd make use of the
$file, $id
parameters passed into your custom function for that - e.g.Btw, I don't really understand
$webPath = '/mapas/uploads/' .$nombre;
in your code.$nombre
is just the stringfilename
so the path would always be/mapas/uploads/filename/...
?Allan
Hi Allan thanks for the reply,
With this shape it works perfectly.
In this case I need to keep the name of the image file being uploaded. One option I have seen is to force the filename field to have unique values in the database. The error it produces in the editor is not very elegant, but I will find a way to prevent duplicates and that I can customize it.
Thank you very much