Hey guys,
I want to perform paddedResize on an image object, I think I've sub-classed the image class correctly but the edited image isn't coming through into the template. Would really appreciate it if someone could have a quick look at this for me:
ContractsPage.php:
class ContractPage extends Page {
static $singular_name = 'Contract';
static $allowed_children = 'none';
static $can_be_root = false;
public static $db = array(
"start" => "Varchar(50)",
"end" => "Varchar(50)",
"Type" => "Varchar(20)",
);
static $has_one = array(
'Logo' => 'ContractPage_ResizedImage'
);
function getCMSFields() {
$typeOptions = array(
'Project Management' => 'Project Management',
'Business Support' => 'Business Support',
);
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new DropdownField('Type', 'Type', $typeOptions));
$fields->addFieldToTab('Root.Content.Main', new DateField('start', 'Start Date'));
$fields->addFieldToTab('Root.Content.Main', new DateField('end', 'End Date'));
$fields->addFieldToTab('Root.Content.Main', new ImageField("Logo"));
return $fields;
}
}
class ContractPage_Controller extends Page_Controller {
}
class ContractPage_ResizedImage extends Image {
function generateResizedImage($gd) {
$gd->setQuality(100);
return $gd->paddedResize(100,83);
}
}
Includes\Contracts.ss:
<% if URLSegment != contracts %>
<div id="contractsTitleBox">
<% control ContractPage_ResizedImage %>
$Logo.ResizedImage.URL
<% end_control %>
<h2>$Title</h2>
...