Web developers wiki ASP.NET Sitecore Sharepoint Kentico by Evident Interactive

Sitecore 6 Image Size Validator

Modified: 2010/07/09 13:46 by Vincevanm - Categorized as: Sitecore
This "Image Size" validator checks the max. size (in kB) of an image that is selected in an image field. You can specify the maximum size in the "parameters" field.

Of course Sitecore has a flexible image scaling functionality that makes a image use less bandwidth but that functionality is especially useful if you want to restrict the dimensions of an image.

An example where you can use this validator is if you want to feed images to Flash. This will prevent users from selecting images that are (for example) over 1MB.

So in short: If you want to restrict the max. size of a Media Library image that a editor can select this validator is for you. You can override the error level yourself (as explained in Sitecore Client Configuration Documentation)

1. Include validator class in your solution
2. Add a Validator Rule in \sitecore\system\settings\validation rules\field rules\
3. In the "type" field point to your namespace,class & assembly. For example: EviSitecore.Validators.ImageSizeKBs,Sitecore62Playground
4. In the "Parameter" field you can use the "MaxSize" parameter to set the max size in Kb. You can use Result to override the error level. Example: "MaxSize=500&Result=FatalError"


 © Evident Interactive BV