How are you so sure that the maximum dimensions are triggering the 500 error. Do you have some sort of logged message of this?
Anyways I found a script that with some changes would solve your wish: GitHub Snippet.
I’m not completely sure whether $file
contains the dimensions. If so this filter could be the soluction.
-
This reply was modified 3 years, 2 months ago by
basvandijkk.
-
This reply was modified 3 years, 2 months ago by
basvandijkk.
Thread Starter
gorvie
(@gorvie)
Tried this code but, seems to be for image size only. Trying to figure out how to apply dimensions rather than size.
If i could just fix the issue of users not being able to load large photos that would be nice.. I recall media page giving error saying try photo that is less than 2500 x 2500 etc. i see that users attempt to upload 3000 x 3000 and that’s when they hit the 500 error. The post still goes through, just the featured image isnt set..
But the code provided ghosts the image when user uploads large photos, but no error message and the post still goes through, just no image.
Idealy trying to get something that blocks large photos based on their dimensions and returns message (preferably)
Thanks again
Thread Starter
gorvie
(@gorvie)
Ok i found this code to limit dimensions. seems to work.
https://www.webempresa.com/foro/administracion-wordpress/limitar-tamano-de-imagen-subida-a-la-libreria-multimedia
Only issue is that there is no warning that image is too large, etc. the post still gets published but just with a blank image. This is better than the 500 error althoe.
Any idea how to tweak it to show warning and disable the use of large photos etc?
thanks
Nice that seems to be a way indeed. Getting the dimensions like that! What happens when you return false;
when the image doesn’t meet your conditions?
Thread Starter
gorvie
(@gorvie)
Sorry for the late response. Had to take some down time.. I tried return false; but didn’t seem to do anything. When image is too large, it wont set.. just a fallback thumbnail. I put a warning on the upload page saying photo must be 2500 x 2500 or under but it seems people are still uploading larger photos resulting in the default thumbnail. Would be ideal to return error telling them photo is too large.
the code im using in functions seems to show a error but im not seeing it happen on my end:
https://www.webempresa.com/foro/administracion-wordpress/limitar-tamano-de-imagen-subida-a-la-libreria-multimedia
Any other ideas?
Thanks again.
I came across this post: StackExchange
I know I already pointed you to this filter. But it really looks like this is the solution. I could help you further if I know more about your code. Like the PHP side about how the form is being handled.
Thread Starter
gorvie
(@gorvie)
I was able to find this in the thread: https://wordpress.org/plugins/imsanity/
Seems to be working. Resizes large images when uploading.
Thank you for your time and help. Was really an issue that needed to fix.
Amazing.
Glad you found a solution!
-
This reply was modified 3 years, 2 months ago by
basvandijkk. Reason: grammar