Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Image size should not exceed greater than 20kb

Avatar

Level 1

Hi,

I have requirement to create an image component with some properties.

1) while authoring the image in dailog box, it should  fetch from damadmin and should not exceed the size limit greater than 20kb.

 

NOTE: The size limit should not be defined in dam admin. we need to restrict only in aem dailog box

 

 

@smacdonald2008 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@Siddu9631,

This is possible, what I would do is:

1. Create a servlet (assetSizeServlet.class) that returns the size of any asset that lives in the DAM; servlet will only be used for the authoring environment.

2. Create new jQuery Validation Plugin, JVP, which will ping the servlet, passing in the path of the image; this will return the size of the asset, and your JVP's JavaScript business logic will display an error message from the toolbar as prompt. 

This is an example of how a new JVP is created for a Touch UI experience, https://sourcedcode.com/blog/aem/touch-ui/aem-richtext-max-characters-length-validation. Take a read of this article, you can see, the JVP will validate form fields and display error messages.

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

@Siddu9631,

This is possible, what I would do is:

1. Create a servlet (assetSizeServlet.class) that returns the size of any asset that lives in the DAM; servlet will only be used for the authoring environment.

2. Create new jQuery Validation Plugin, JVP, which will ping the servlet, passing in the path of the image; this will return the size of the asset, and your JVP's JavaScript business logic will display an error message from the toolbar as prompt. 

This is an example of how a new JVP is created for a Touch UI experience, https://sourcedcode.com/blog/aem/touch-ui/aem-richtext-max-characters-length-validation. Take a read of this article, you can see, the JVP will validate form fields and display error messages.