Limiting or validating uploaded image size

Support General Limiting or validating uploaded image sizeResolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #30490
    matijamatija
    Participant

    Hello.

    I have a single image field, how do I set that only images of size 300x250 px can be uploaded to that field? In case any other size, the field should throw a validation error message.

    Many thanks

    #30504
    Long NguyenLong Nguyen
    Moderator

    Hi,

    There is no option/setting to limit the resolution of the uploaded images. You can limit the uploaded file size by using the setting max_file_size of the field image_upload

    Get more details on the documentation https://docs.metabox.io/fields/image-upload/#settings

    #43732

    Hello, and how about a way to use validation callback function to do so? I did not figure out a simple way to implement any kind of validation for images (mostyl sizes of course...). Do I havee to wait the ile is loaded and use validation when the whole metabox is saved to database? Not really nice for user to wait final saving to say "hey sorry your image is not right! But I could not tell you before you saved your whole page..."

    #43749
    PeterPeter
    Moderator

    Hello,

    There are two JS validation rules for image/file field: extension and accept, but not image/file size. Please read more in the documentation https://docs.metabox.io/validation/#advanced-validation

    For the image size, please follow the suggested above.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.