Where can I find info on controlling image sizes.?
I have a pull down in my cms "CSSBoxStyle" and based on that pull down value i want to set the size of the image displayed.
if they choose nostyle then its 218 pixels wide
else its 294 pixels wide
i'm struggling with my if statements
Is it best to do this in the SS file or the PHP image class?
example PHP
<?php
class RightContent extends DataObject {
static $db = array(
'Title' => 'Text',
'Description' => 'HTMLText',
'ImageLink' => 'Varchar(255)',
'CSSBoxStyle' => "Enum('styleone, styletwo, stylethree, stylefour, nostyle')"
);
static $singular_name = 'RightContent';
static $plural_name = 'RightContents';
static $has_one = array(
'Page' => 'Page',
'SideScreenImage' => 'RightContent_SideScreenImage'
);
static $defaults = array(
'Title' => ''
);
public function getCMSFields_forPopup() {
$fields = new FieldSet(
new ImageField('SideScreenImage','MainImage (Optional)'),
new TextField('ImageLink', 'Add URL Link to Image (Optional)'),
new TextField('Title', 'Title'),
new SimpleHTMLEditorField('Description','HTML'),
new DropdownField('CSSBoxStyle', 'CSSBoxStyle', singleton('RightContent')->dbObject('CSSBoxStyle')->enumValues())
//'getCMSFields_forPopup'
);
return $fields;
} //getCMSFields_forPopup
} //dataobject
class RightContent_SideScreenImage extends Image {
function generateWebsiteThumnail($gd) {
$gd->setQuality(80);
//if nostyle is chosen i want it to be 218
return $gd->ResizeByWidth(218);
//return $gd->ResizeByWidth(194);
}
}
?>
SS file
<% control RightContents %>
<% control SideScreenImage %>
$SetWidth(218)
<% end_control %>
<% end_control %>