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.

Themes /

Discuss SilverStripe Themes.

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

Resizing picture in templete


Go to End


2 Posts   5857 Views

Avatar
anujkryadav

Community Member, 30 Posts

14 March 2010 at 9:02pm

Edited: 14/03/2010 9:02pm

i am trying to resize a picture in template but it is giving me error
the code i have tried are

$Photo.SetSize(80 , 80)
$Photo.SetSize(80, 80)
$Photo.SetSize(80,80)

error i have received is

Missing argument 1 for Image::SetSize()

and

$Photo.PaddedImage(80, 80)
$Photo.PaddedImage(80,80)
$Photo.PaddedImage(80 , 80)

the error i have received is

imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions

I am trying to resize the image without cropping it.

when i am calling only the variable its showing the picture

thank you in advance

Avatar
3dgoo

Community Member, 135 Posts

6 May 2010 at 12:27pm

Edited: 06/05/2010 12:30pm

Should work according to this:
http://doc.silverstripe.org/image

I'm too lazy to test this right now, sorry.

Another way to do this is through a conrol. Have a read of this:
http://www.ssbits.com/resizing-an-image-in-a-custom-img-tag/

<% control Photo %>
	<% control PaddedImage(80, 80) %>
		<img src="$URL" alt="A cropped image" />
	<% end_control %>
<% end_control %>

Sorry about the late reply.