How can I require specific dimensions for an image for an upload form? For example, I want to set the image to be uploaded in 350x200px, or show a notice to the user if the image size is not correct.

Alternatively, can I set a minimum upload size?


Add these code to your theme function file.

add_image_size('mythumb', 350, 200, array( 'left', 'top' ));
// third parameter is for cropped option, you can change that as your preference.
the_post_thumbnail( 'mythumb' );// image with the new dimensions.

Important: you need to regenerate thumbnails to make this work. You can use plugin for that. For complete study, check official guide: https://codex.wordpress.org/Function_Reference/add_image_size

  • Hi, I'm using dokan plugin, will this work? – pryde1919 Jul 12 '15 at 14:56
  • My answer is wrong for your requirement, Please follow the possible duplicate link to get the solution specific to your requirement. – Rituparna sonowal Jul 12 '15 at 18:18
  • Can I use a javascript inside the php? may I ask the script? – pryde1919 Jul 13 '15 at 12:31
  • Yes you can. <?php //your php code. ?><script> Your javaScript code. </script><?php //your php code ?> – Rituparna sonowal Jul 13 '15 at 12:50

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