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.

Customising the CMS /

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

Image gallery - how to resize


Go to End


1782 Views

Avatar
Trym

Community Member, 18 Posts

18 March 2009 at 7:57pm

Edited: 18/03/2009 8:00pm

Hi

I need to resize the images in my gallery before sending them to the client browser. The images have sizes of 500 kb (but resized only about 50 kb).

I have in Page.php created a function
function FrontPageRotator() {
return DataObject::get("Image", "`ParentID` = 31");
}

And in Page.ss the following template code
<% if FrontPageRotator %>
<% control FrontPageRotator %>
<img class="frame" src="$Link" style="display:<% if First %>block;<% else %>none;<% end_if %>" width="270" height="220"/>
<% end_control %>
<% end_if %>

I wanted to have $Image.setWidth(140) instead of $Link, but I dont seem to be able to refer to $Image.
Can anyone help?

Thanks in advance.

Best regards Trym