[SOLVED] CGSmartImage max width and height

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
McF
Forum Members
Forum Members
Posts: 108
Joined: Thu Dec 27, 2007 5:27 pm

[SOLVED] CGSmartImage max width and height

Post by McF »

Hello,

I saw caution "Image processing functions are deprecated..." in Products module and started to use CGSmartImage module.

Great image processing module.
But I have problems with setting maximum width or height of re-sized photo...

Code: Select all

{capture assign=artwork}{$entry->file_location}/{$entry->fields.artwork->value}{/capture}
{CGSmartImage src=$artwork filter_resizetofit="100,100"}
{CGSmartImage src=$artwork filter_resize="w,100" filter_resize="h,100"}
{CGSmartImage src=$artwork width="100" height="100"}
{cgsi_convert max_width="100" max_height="100"}{CGSmartImage src=$artwork}{/cgsi_convert} 
None of above is not working as I need. Last approach do not show image at all.

McF
Last edited by McF on Wed Jan 18, 2012 6:10 pm, edited 1 time in total.
McF
Forum Members
Forum Members
Posts: 108
Joined: Thu Dec 27, 2007 5:27 pm

Re: CGSmartImage max width and height

Post by McF »

Solved.

Using PHP function getimagesize I get width and height. Then I compare width with height and use CGSmartImage depending on which measurement is greater.

Code: Select all

{capture assign=image}{$entry->file_location}/{$entry->fields.image->value}{/capture}
{assign var="image_atr" value=$image|getimagesize}
{if $image_atr[0] gt $image_atr[1]}
  {CGSmartImage src=$image filter_resize="w,100"}
{else}
  {CGSmartImage src=$image filter_resize="h,100"}
{/if}
dmgd
Forum Members
Forum Members
Posts: 115
Joined: Tue Jun 06, 2006 1:10 pm
Location: TX

Re: CGSmartImage max width and height

Post by dmgd »

Thanks I need this. I tried the tag {cgsi_convert} and could never get it to work.
Post Reply

Return to “Modules/Add-Ons”