Media Selection custom validation

Tomasz Czado asked on July 5, 2019 09:21

Hi,

is there a way to validate image minimum width and height for field? I have custom page type with field that uses Media Selection form controls. I would like to see if selected image size is not smaller then defined width and height.

Correct Answer

Dmitry Bastron answered on July 5, 2019 11:39

Hi Tomasz!

This scenario is not supported by defaul Media Selection control. The easiest would be to specify Validayion rule against your field like this:

Image Text

All you need to do is to implement this custom macro rule ValidateImageSize(mediaUrl, minWidth, minHeight). So in macro rule you need to:

  • get MediaFileInfo object by URL (you can cut image GUID from URL and find by GUID)
  • check media file width and height against your borders, that's it!
1 votesVote for this answer Unmark Correct answer

Recent Answers


Elias Dominguez answered on June 11, 2020 19:53

How do you specify the object id on the k# validation {}?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.