Modify pre-defined crop settings

Hello Mark,
is there a way to modify those 9 pre-defined Aspec ratio crop settings in the right panel of cropper dialog? Was trying to find somewhere but no luck. This would be great to give editors a choice from a few allowed formats, not forcing them to particular one.

1 Like

At the moment those are not configurable. Either there’s a fixed ratio in your crop definition, or all options are available.

One kinda hack-ish thing you could consider is registering a custom CSS file that hides the ratio you don’t want from the interface. For example something like this:

label[for=cropper-ratio-1.77] {
    display: none;
}

(Might need some escaping in the attribute bit - haven’t tested)

In a meantime, I have already figured it out. It’s freely configurable. 2 steps are needed:

  1. edit image_cropper.tpl and inside ul class=“cropper-ratios” you can remove individual li’s or add custom ones like this for e.g. 24:9 aspect ratio:

             <li>
                 <input type="radio" name="ratio" value="2.67" id="cropper-ratio-2.67">
                 <label for="cropper-ratio-2.67">
                     <div class="cropper-ratio" style="width: 4em; height: 2em;"></div>
                     {%=_('contentblocks.cropper.aspect_ratio.24_9')%}
                 </label>
             </li> 
    
  2. add corresponding lexicon entry for label, e.g. namespace=“contentblocks”, topic=“default”, name=“contentblocks.cropper.aspect_ratio.24_9”, value=“24:9”

Only problem I can see is that any future CB update will reverti this back to default settings.

Correct and very important to realize. Changes to those templates are not safe from updates and not recommended.