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.

General Questions /

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

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

Resizing an image within a form




Community Member, 129 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