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

resize by ratio?


Go to End


2 Posts   2099 Views

Avatar
janulka

Community Member, 80 Posts

30 December 2009 at 10:39am

Hello,

In my template I would like to use image which will be resized by ratio, and I need to use "control" method to to that..

e.g.
<% control ResizedImage(150,150) %> - will resize image, skews if necessary
<% control CroppedImage(150,150) %> - crops image

what is the code for this to do resizing by ratio?

thanks a lot in advance!

Avatar
baba-papa

Community Member, 279 Posts

1 January 2010 at 4:44am

I presume that your images have a 1:1 relation to an object.

<% control relationName %>
$Image.SetRatioSize(80,80)
<% end_control %>

Have a look at the documentation:
http://doc.silverstripe.org/doku.php?id=image