Page 1 of 1

Help using CGSmartImage - i should know, but don't.

Posted: Sun Jan 04, 2015 3:26 am
by pwg
Hi,

Another silly question, this time about using CGSmartImage in my templates.

Previously I have manually resized images prior to uploading and have been happy (enough) for thumbnails to be compressed by the browser, as i figured the images would then be cached and the detail page load quicker.

However i'd like to start using CGSmartImage as expecting clients to resize accurately is too much.

My summary template contains

Code: Select all

 {if $field->type == 'file'}
          <img src="{$entry->file_location}/{$field->value}"/>
        {else}
<a href="{$entry->detail_url}" title="{$entry->title|cms_escape:htmlall}">{eval var=$field->value}</a>
        {/if}
How do I code it so that I'm adding something like {CGSmartImage notag="1" filter_croptofit="267,400,c"} to my template?

Thanks for any help - i realise i should know this stuff - but i don't.

Cheers,

Paul

Re: Help using CGSmartImage - i should know, but don't.

Posted: Sun Jan 04, 2015 11:00 pm
by Dr.CSS
I've never used it but would look in the modules Help page, most likely some code in there...

Re: Help using CGSmartImage - i should know, but don't.

Posted: Sun Jan 04, 2015 11:19 pm
by pwg
Thanks Dr, had a good read of the help section, but I don't think I know enough to know!

Re: Help using CGSmartImage - i should know, but don't.

Posted: Mon Jan 05, 2015 8:30 am
by scooper
Here's an example from a template we use that looks like the kind of thing you need (from this blog page ).

Code: Select all

{if $entry->fields['Featured Image']->value ne ''}
 {assign var='altText' value=$entry->fields['Image alt text']->value}
 {CGSmartImage src="`$entry->file_location`/`$entry->fields['Featured Image']->value`" filter_croptofit="170,170" alt="$altText" title="$altText"}
{else}
<img src="/lib/layout/default_170px.png" alt="">
{/if}
getting the quotes sorted can be a bit fiddly but hopefully that should get you going.

Re: Help using CGSmartImage - i should know, but don't.

Posted: Mon Jan 05, 2015 11:16 am
by velden
CGSI has some nice parameters (src1 & src2) to prevent the backtick-trick:

Code: Select all

{CGSmartImage src1=$entry->file_location src2=$entry->fields['Featured Image']->value filter_croptofit="170,170" alt="$altText" title="$altText"}

Re: Help using CGSmartImage - i should know, but don't.

Posted: Fri Jan 16, 2015 9:11 am
by jack4ya
And here I was assigning filepaths/filename combo's... ;)
Nice to know the src1 and src2 options.