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

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
pwg
Forum Members
Forum Members
Posts: 191
Joined: Tue Aug 01, 2006 1:48 am

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

Post 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
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

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

Post by Dr.CSS »

I've never used it but would look in the modules Help page, most likely some code in there...
pwg
Forum Members
Forum Members
Posts: 191
Joined: Tue Aug 01, 2006 1:48 am

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

Post by pwg »

Thanks Dr, had a good read of the help section, but I don't think I know enough to know!
scooper
Forum Members
Forum Members
Posts: 242
Joined: Fri Dec 09, 2005 12:36 pm

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

Post 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.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

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

Post 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"}
jack4ya
Power Poster
Power Poster
Posts: 294
Joined: Thu Oct 19, 2006 10:07 am

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

Post by jack4ya »

And here I was assigning filepaths/filename combo's... ;)
Nice to know the src1 and src2 options.
Post Reply

Return to “The Lounge”