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

html5smartImage disable free crop and set a default crop config

Avatar

Level 2

Hello,

 

I have two questions: 

 

Is it possible to disable the free crop, yet, retain and use other custom defined crop configurations. We do not want authors to crop the image using the free form tool, but, should be able to crop based on the pre-defined crop dimensions. 

 

Is it possible to apply a default crop config on the image as soon as "crop" is clicked or image is loaded in to the html5smartImage. 

 

I'm not looking to extend/create my own component based on html5msartImage, rather wondering whether there is any config or ootb way to do it?

From my understanding, this cannot be achieved, wanted experts here to validate me.

 

Best,

Sivaram

1 Accepted Solution

Avatar

Correct answer by
Level 8

I don't know of anyway to do that doesn't at least involve overriding the dialog file for the image component in /apps. By overriding the dialog in /apps/foundation/components/image you could disable the free crop, and then you use a hidden x-type to set the crop dimensions. 

One thing to consider about this approach is that it locks your default crop size into the content of the component, so if for some reason in the future you wanted to change those default dimensions you'd have to write a script that would go through and alter all of you existing content. There are some alternate solutions your could consider:

  1. The image component has a design dialog that allows you to set a max height and max width settings. You could override this dialog and change it to allow you to store crop settings. This would potentially be sub-optimal because the user editing the dialog would have to understand the syntax of crop settings, but it is possible. 
  2. You could also look at overriding /libs/foundation/components/parbase/img.GET.java at /apps/foundation/components/parbase/img.GET.java add your crop logic there. You might pair that with overriding the image dialog and turning of the free crop and adding a radio button for crop. 

View solution in original post

0 Replies

Avatar

Correct answer by
Level 8

I don't know of anyway to do that doesn't at least involve overriding the dialog file for the image component in /apps. By overriding the dialog in /apps/foundation/components/image you could disable the free crop, and then you use a hidden x-type to set the crop dimensions. 

One thing to consider about this approach is that it locks your default crop size into the content of the component, so if for some reason in the future you wanted to change those default dimensions you'd have to write a script that would go through and alter all of you existing content. There are some alternate solutions your could consider:

  1. The image component has a design dialog that allows you to set a max height and max width settings. You could override this dialog and change it to allow you to store crop settings. This would potentially be sub-optimal because the user editing the dialog would have to understand the syntax of crop settings, but it is possible. 
  2. You could also look at overriding /libs/foundation/components/parbase/img.GET.java at /apps/foundation/components/parbase/img.GET.java add your crop logic there. You might pair that with overriding the image dialog and turning of the free crop and adding a radio button for crop.