html5smartImage disable free crop and set a default crop config | Community
Skip to main content
Level 2
October 16, 2015
Solved

html5smartImage disable free crop and set a default crop config

  • October 16, 2015
  • 1 reply
  • 970 views

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

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 PaulMcMahon

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. 

1 reply

PaulMcMahonAccepted solution
Level 8
October 16, 2015

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.