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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How to resize only big images ?


Go to End


4 Posts   3735 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