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 Crop in Template


Go to End


3 Posts   7875 Views

Avatar
BuddhaSource

Community Member, 57 Posts

21 April 2011 at 12:48am

I love the $Image.SetSize(80,80) functions in template. I needed more options in template :).

1. How do I crop image from template. eg $Image.Crop(80,80)

2. As a work around I also tried using background image but I cannot not resize the image for background

<div style="background-image('$Image.URL'); height: 80px;">

Avatar
swaiba

Forum Moderator, 1899 Posts

21 April 2011 at 2:23am

Avatar
BuddhaSource

Community Member, 57 Posts

21 April 2011 at 2:40am

Thanks swaiba

Worked like a charm :)

<% control Image %>
	<img src="$CroppedImage(200,200).URL" alt="$Title" />
<% end_control %>

I got this code before but did not specify right controller. In my case its <%control Photo %> :)