hi
i went through this tutorial covering image resizing. i initially tried modifying it to work within a dataObject, but when that failed i went back and copied it word for word to no avail.
from what i can gather it seems the BannerImage isn't getting created at all. at least when i look in the assets folder i can other resampled images, CMSThumbnail and a few SetWidth/ResizedImage versions too.
i'm guessing it's something really small, and really dumb that i've overlooked.
class Page extends SiteTree {
static $db = array(
'featuredTitle' => 'Text'
);
static $has_one = array(
'BannerImage' => 'Image'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new TextField('featuredTitle','Headline'));
$fields->addFieldToTab('Root.Content.MyBannerImage', new ImageField('BannerImage','Featured Image'));
return $fields;
}
}
class Page_Controller extends ContentController {
function init() {
parent::init();
}
}
class Page_BannerImage extends Image {
function generatePageBanner($gd) {
$gd->setQuality(100);
return $gd->paddedResize(619,154);
}
}
in page.ss i have
<% if BannerImage.PageBanner %>
<img class="headerImage" src="$BannerImage.PageBanner.URL" alt="Header banner" />
<% else %>
<% control Page(home) %>
<img class="headerImage" src="$BannerImage.PageBanner.URL" alt="Header banner" />
<% end_control %>
<% end_if %>
thanks in advance