Page 1 of 1

A Smart Image Cropping Question

Posted: Tue Nov 19, 2024 11:52 pm
by Andrew Prior
Folks, I use the excellent Portage template for my website and have the Smart Image "Default location from which to "crop to fit" set to center crop.

I also set up a website for a workplace, and we looked at what we needed and paid money for a set of "bottom croppable" photos for the page headers.

But now I have a friend who is an accomplished photographer and who wants to use their existing photos. Here is the problem: Some of them clearly need to be set to center crop and others will only work if set to bottom crop. (And a few would work with crop right and crop left.)

I see in the help files there is the option to add the filter_croptofit attribute to a template where I can specify which crop to use, so if I am correct in my understanding of that filter, I could specify two or three templates which would allow said friend to choose the appropriate cropping for the relevant photo… except that Portage uses a master template. And as such, any template using Smart Image in the header gets the settings from that single master template. I can't see that I can set up multiple master templates 😊

Do I have any options here, or must I tell my mate Olly he has to suck up and choose only the photos that fit just one of the cropping defaults?

Andrea

Re: A Smart Image Cropping Question

Posted: Wed Nov 20, 2024 12:03 am
by DIGI3
You can pass variables from child templates to parent templates if you put them in scope. So in your master template if you had something like:

Code: Select all

{SmartImage src=$myimage filter_croptofit='1200,400,$location|default:c,1'}
Then in your child template something that passes $location as tl,tc,tr, etc., like {$location='tl' scope=global}. That could be a dropdown field (using ECB2, for example) or whatever method you want. I don't think you'd need a separate template for each crop type but that works if you want to.

Re: A Smart Image Cropping Question

Posted: Wed Nov 20, 2024 12:54 am
by Andrew Prior
Awesome! Thank you. I'll have a play :) Andrea