Image size should not exceed greater than 20kb | Community
Skip to main content
October 8, 2021
Solved

Image size should not exceed greater than 20kb

  • October 8, 2021
  • 1 reply
  • 1108 views

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 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by BrianKasingli

@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.

1 reply

BrianKasingli
Community Advisor and Adobe Champion
BrianKasingliCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
October 8, 2021

@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.