Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Image size should not exceed greater than 20kb

Siddu9631
Level 1
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
BrianKasingli
Correct answer by
Community Advisor
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
BrianKasingli
Correct answer by
Community Advisor
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