Hi, do you have any example code to restrict the featured in image being submitted in a form to the exact image dimensions?
1920 by 962 pixels. Thanks
You would need to disable using the WP Media Uploader in the form settings, and could then use the cred_form_validate hook to check and accept or reject the image based on its dimensions (https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate).
I'm not sure that is a very good workflow though: it involves uploading the image to the server when the form is submitted, running the validation test, and rejecting the form if the image doesn't match the requirements. Your users would have waited for the image to upload for nothing.
Why not register a custom image size with those dimensions? Then when the image is uploaded WordPress will automatically generate an image of that size (subject to the cropping and resizing settings you specify).
See https://developer.wordpress.org/reference/functions/add_image_size/
Also, there are lots of tutorials around this subject, e.g. hidden link
Great! thanks for the workaround.