Im facing a problem, we've got several clients who really don't care about what size images they upload but then come to use later in time to ask why the site is slow.

So as a solution I would want to STOP any file being uploaded if its bigger than 1mb or maybe .5mb that way there gonna have resize it make it smaller before uploading it.

As currently I'm trying to speed up a site by compressing images but some of these images are 5mb+ and I'm having to manually remove them and re upload them at a smaller size which is a time consuming task.

I know there are several plugins out there but don't really want to pay for it, if its possible free.

Any help would be greatly appreciated.

  • There are several good free plugins available. This site mostly shies away from recommending specific ones since they may not be available in the future, but if you search for image optimization, you'll find options. Instead of preventing uploads they typically let you set max image dimensions and compression levels, and they do the resizing behind the scenes. Some can also go back and compress previously uploaded images, as well as future uploads.
    – WebElaine
    Jul 6, 2018 at 14:08

1 Answer 1


There are several free programs for manually resizing images, such as ImageOptim, which can bulk optimize images. I know you said you looked at plugins, but in case you missed it EWWW Image Optimizer is free to use if you run it on your server and don't need to hook into their API for additional tools, just have one of these installed on the server:

jpegtran, optipng, pngout, pngquant, gifsicle, cwebp

Finally, if you want to decrease the upload size, then do it the same way you would for increasing upload size but make the numbers smaller:

In your php.ini:

upload_max_filesize = 0.5M
  • but what if you dont want to change it globally / dont have access to the php.ini is there a hook for the media upload sequence and check if an image is over a certain kb and if so stop the image from being uploaded.
    – JoshTalk
    Jul 12, 2018 at 21:08
  • There is a filter for the max upload size: upload_size_limit, you can find out more here: developer.wordpress.org/reference/hooks/upload_size_limit
    – phatskat
    Jul 20, 2018 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.