Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions /

How to resize only big images ?


Reply


4 Posts   2402 Views

Avatar
Bibich

Community Member, 12 Posts

21 December 2008 at 1:37am

Hi,

In my template, I show an image on the top of the page. The images have differents sizes. I want to resize image only if the image is bigger than 450px width or 250px height. For the moment, I'm using :

<% $Photo.SetWidth(450) %>


where Photo is an ImageField

The problem with this is that if the image is smaller it resize it bigger (poor quality) and if the image is vertical the resize's image is too big.

an issue ?

Thank's. Julien C.

Avatar
Liam

Community Member, 470 Posts

21 December 2008 at 8:25am

Checkout the GD functions.

http://doc.silverstripe.com/doku.php?id=gd

Avatar
Bibich

Community Member, 12 Posts

22 December 2008 at 2:10am

Ok,

but I don't know where to use it. I have to change Image.php (model) ?

Julien.

Avatar
Bibich

Community Member, 12 Posts

22 December 2008 at 3:03am

I have found an example : http://doc.silverstripe.com/doku.php?id=recipes:customising_image

Thank's. Julien