Forum Replies Created
-
AuthorPosts
-
March 5, 2017 at 1:48 PM in reply to: How to display a custom file upload error in a plupload_image field? #5215
tgarda
ParticipantHi Anh,
I tested the max_file_size parameter and it works well for stopping users from uploading large images. Thank you very much for this update!
On the other hand, I was trying to figure out how to display a custom error message in the plupload_image Metabox when somebody is trying to upload a file with a size that exceeds max_file_size. Based on what I have read so far, it looks like I have to use javascript / jQuery to do that. Can you confirm that is correct? Or is there a WordPress hook do do it? I would appreciate any guidance or hint I can research further. I do not expect a tested, working sample : )
Thanks again.
January 30, 2017 at 10:36 AM in reply to: How to prevent uploads for plupload_image field type? #4930tgarda
ParticipantHi Anh,
Thank you for the feedback! In the meantime, I implemented a solution to automatically resize the original images after uploading if they are too large using the wp_handle_upload filter. That works and I do not need the functionality to stop uploading. It is probably a good practice not to delete images anyway, you never know what other plugins or themes expect in the Media Library. So this thread can be closed as far as I am concerned.
However, I will open another thread for the functionality of propagating an error about exceeding the max image size limit when trying to upload a file and displaying the error on the GUI in the plupload_image field. Perhaps the way to do that is to set $file['error'] in the same wp_handle_upload_prefilter as in my earlier example in this thread. Perhaps there is a better way to do it. In any case, thanks again for your feedback here!
January 25, 2017 at 6:07 AM in reply to: How to prevent uploads for plupload_image field type? #4911tgarda
ParticipantForgot to mention that setting upload_max_filesize in php.ini is not sufficient for me. I want to set different size limits based on file type (e.g. images / videos / other types should have different limitations.) I know how to check the file type. The only piece missing is stopping the file upload.
-
AuthorPosts