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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Resizing an image within a form


Go to End


908 Views

Avatar
joelg

Community Member, 134 Posts

1 July 2010 at 9:20pm

Hi there

How can I resize an image inside a form?

Suppose I would like to do something like this:

function ImageForm()
{
	$Employee = Employee::currentUser();
	$Image = $Employee->Picture();
		
	$form = new Form($this, "Form", 
                      new FieldSet(
		            new LiteralField(''myLiteralField", $Image->paddedResize(200,200)
                      ), 
		      new FieldSet(
		            new FormAction ($action = "myAction", $title = "Save")
                      ), 
                      new RequiredFields());
	
        //I know there is actually no formfields in this form, this is just an example...
		
	return $form;
}

Thanks, Joel