Image and asset upload validation
Description
Uploaded files can be validated before they are processed. This means validating properties like file size and file extension or more specific ones like image resolution.
The validation services are used in the following sections:
- GalleryWorkflowPlugin: this plugin takes care of uploading image/asset files to a image/asset folder via the context menu "Add image"/"Add file".
- ImageUploadPlugin/ResourceUploadPlugin: these plugins are used to upload an image variant (e.g. thumnail variant) or an asset file when editing an image/asset.
- The image picker dialog in the CKEditor: uploading file via the image picker will be validated by the image validation service.
By default, the file upload plugin will try to load an instance of the org.hippoecm.frontend.plugins.yui.upload.validation.FileUploadValidationService by looking up a service specified by property validator.id. If no specific service is found, the DefaultUploadValidationService is used.
Configuration
The DefaultUploadValidationService will validate file size and file extension(s). It can be configured at /hippo:configuration/hippo:frontend/cms/cms-services/assetValidationService.
Property | Type | Description | Default value |
max.file.size |
String |
Maximum file size allowed per file. The value is converted using Wicket's Bytes.valueOf() |
10mb |
extensions.allowed |
String multiple |
File extensions allowed. Values are configured as *.jpg, *.png, etc. Leave blank for all extensions. |
|
mimetypes.allowed (since CMS 4.0.2) |
String multiple |
Mime types allowed. |
The ImageUploadValidationService extends the DefaultUploadValidationService and adds validation of the image resolution as well as more image specific default values.
It is located at /hippo:configuration/hippo:frontend/cms/cms-services/imageValidationService.
Property | Type | Description | Default value |
max.file.size |
String |
Maximum file size allowed per file. The value is converted using Wicket's Bytes.valueOf() |
4mb |
extensions.allowed |
String multiple |
File extensions allowed. Values are configured as *.jpg, *.png, etc. Leave blank for all extensions. |
*.jpg, *.jpeg, *.gif, *.png |
mimetypes.allowed (since CMS 4.0.2) |
String multiple |
Mime types allowed. |
|
max.width |
Long |
Maximum horizontal number of pixels allowed. |
1920 |
max.height |
Long |
Maximum vertical number of pixels allowed. |
1280 |