I'm developing my own theme where I have fixed the left sidebar with my photo. Is it possible to force users to crop their image to a square during upload? If yes, how? What functions I will need?

1 Answer 1


Your assumption that all images are uploaded from a browser is false. Currently images can be uploaded via the XML-RPC protocol and once the REST API will be merged it will also be used to upload images.

Images can also be imported from other sites.

The point is that you should not assume that images are fitting the design. If you need images to look the best they can then you want not the cropped version but the full one and then let a pro designer to work on then to crop and fix them.

  • Ok, I see. So I ask, is possible force crop image after select? (Example: Theme Options->logo->upload/i select already uploaded image->crop->upload->save) I hope you understand me. Nov 9, 2015 at 19:58
  • 1
    Yes you can crop the image after it has been uploaded to the server. Actually wordpress will do it automatically for several sizes, and you can add your own size by using the add_image_size API developer.wordpress.org/reference/functions/add_image_size, or write your own upload handler (there are many examples even on this site , just google for them). Nov 9, 2015 at 20:13
  • And can I use add_image_size for something else like post thumbnail? Example for get_theme_mod( 'image' )? Nov 9, 2015 at 20:26
  • add_image_size will cause all images uploaded via the wordpress API to automatically be cropped into the requested size. If you have a code that selects an image from the media library (so you get the image id), you can use get_attachment_image codex.wordpress.org/Function_Reference/wp_get_attachment_image to get the actual image tag (other related APIs can give just the url). The key parameter there is the $size which should match the $size you used in add_image_size. Nov 9, 2015 at 20:33

Your Answer

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

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