Is it possible to validate if an image being uploaded to the page conforms to specific dimensions of height or width?
Solved! Go to Solution.
Views
Replies
Total Likes
Thanks for the clarification, @aem-explorer!
There are different approaches to this requirement.
You could most probably build a custom validation based on Granite UIs foundation validation as outlined here.
On the other hand, you could leverage renditions or smart cropping to ensure that all your assets do have proper variations to fit all available components, view ports, etc.
Hope that helps!
To address the issue of invalid image dimensions, you can implement a workflow that automates the detection and handling of such images. Here's a proposed solution:
Invalid Image Detection: First, we will set up a workflow that monitors newly uploaded images for their dimensions; in a particular folder path. When an image with invalid dimensions is detected, the next workflow will be triggered.
Automated Deletion: The workflow will then automatically delete the image to prevent it from being stored in the system. This step ensures that only images meeting our required dimensions are retained.
Author Notification: Simultaneously, the workflow will generate a notification that is sent to the author responsible for the image upload. This notification will clearly inform the author that the dimensions of the uploaded image were invalid and that the image has been removed as a result.
I hope this helps.
Hi @aem-explorer!
For your use case, there are several things that need to be considered.
First of all, it's not possible to run a validation before the asset is completely uploaded to AEM. So you can't simply "reject" the file to be uploaded or notify the user when he selects the asset on his local computer or during the upload process. You'll have to wait until the asset upload is finished.
Once the upload is finished, you can run a validation workflow as outlined by @BrianKasingli. You could also simply hook-in to the OOTB DAM Asset Update workflow.
However, you'll need to define the desired behavior first. What should happen if a users uploads in image that has invalid dimensions?
That being said, it's worth to consider what "invalid dimensions" means in terms of a business use case. In general, AEM is capable to handle even very large assets (both, in terms of resolution and file size) and it's possible to resize/downsize them for different use cases such as web delivery. Other output channels (e. g. print or further digital asset processing) might require higher/full resolution assets. Dynamic Media can resize assets assets on-the-fly based on various criteria without manual action by a content editor. AEM itself can also resize assets, being it as renditions or even resizing the uploaded original.If you are worried about assets that might be too small and not meet certain quality standards, please be aware that there might be cases where small assets are actually needed (such as decorative images, symbols, tags, previews or similar). Limiting your content authors always takes away some flexibility of the system.
Hope that helps!
@aem-explorer Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.
Views
Replies
Total Likes
I was looking at validation when the author is dragging an image onto a component that does not conform to the height-width suitable for that component? The same image might be good for some other components so I do not want to put blockers for uploading to DAM but rather a validation error when uploading to a component.
Thanks for the clarification, @aem-explorer!
There are different approaches to this requirement.
You could most probably build a custom validation based on Granite UIs foundation validation as outlined here.
On the other hand, you could leverage renditions or smart cropping to ensure that all your assets do have proper variations to fit all available components, view ports, etc.
Hope that helps!
Views
Likes
Replies
Views
Like
Replies