hi, I would like to resize image when user upload a image through cms. I have done my readings and tried to find relative post in the forum. The following is what i have found, but none of them actually solve my problem.
http://doc.silverstripe.com/doku.php?id=imageupload
http://doc.silverstripe.com/doku.php?id=gd
http://doc.silverstripe.com/doku.php?id=simpleimagefield
http://doc.silverstripe.com/doku.php?id=image&s=setwidth
I follow the first article as it is very close to what I want, 'http://doc.silverstripe.com/doku.php?id=imageupload'. Yet something is off, and my script does not work. The following is what I have written.
class AboutUsPage extends Page {
static $db = array(
'Headline' => 'Varchar(255)'
);
static $has_one = array(
'AboutUsImage' => 'AboutUsPage_CustomeImage'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new TextField('Headline'), 'Content');
$fields->addFieldToTab("Root.Content.Images", new ImageField('AboutUsImage','Image'));
return $fields;
}
}
class AboutUsPage_Controller extends Page_Controller {
}
class AboutUsPage_CustomeImage extends Image {
function genertateCustomeImage($gd){
return $gd->resizeByWidth(259);
}
}
Could someone point me to the right direction please?
Thank you for taking your time to read this post!