How to allow user to crop the image, but not make him to do that? Mostly they don’t need to crop, just use original pic, so we don’t open cropper automatically.
For example when crop is not defined template is like this: <img src="[[+url]]" width="[[+width]]">
But when user defines crop (named Free), template should be: <img src="[[+crops.Free.url]]" width="[[+crops.Free.targetWidth]]">
If crop is not defined we need to resize using phpthumbof, when crop is defined we can use it directly.
I tried: <img src="[[+crops.Free.url:default=`[[+url]]`]]" width="[[+crops.Free.targetWidth:default=`[[+width]]`]]">
While crops.Free placeholders are empty, they go into resource content field and break further processing, like phpthumbof.
Is there a way in template to tell if crop is defined and use different code?
Or at least can undefined crop receive default values (url, width,height) from image itself (though not really solving all issues)
Thanks Stefan, but any combination of placeholders and output filters won’t work. Problem is that CB on save won’t process output filters and fill only placeholders with value.
So for example, you don’t create crop and original image is image.jpg (no path for simplicity), this goes to resource content: [[+crops.Free.url:isnot=``:then=`[[+crops.Free.url]]`:else=`image.jpg`]]
If we don’t need any further processing, MODX will process this correctly on page render. But we need to use phpthumof to rescale image to some maximum size, so we call phpthumbof where image path is entire string above. This is obviously not working. Not saying that we need to use phthumbof only when user didn’t created crop, otherwise we use crop directly.
It would be best if CB creates automatically all crops from entire image without opening cropper. If user is not satisfied with result, he or she can open cropper and adjust it later.
When user mostly want to use uncropped images, it’s annoying to open cropper uatomatically. User then needs to stretch crop rectangle to entire image (it’s not by default) and save crop. It’s several extra clicks per image, customers are complaining.