<?php
class ProductIntroductionVideo extends DataObject
{
static $db = array (
'VideoName' => 'Varchar(255)',
'YouTubeVideoID' => 'Varchar(255)'
);
static $has_one = array (
'IntroductionVideoThumbnail' => 'IntroductionVideoThumbnail_CustomImage',
'IntroductionVideoImage' => 'IntroductionVideoImage_CustomImage',
'ParentProductIntroductionPage' => 'ProductIntroductionPage'
);
public function getCMSFields_forPopup()
{
$fields = new FieldSet();
$fields->push( new TextField('YouTubeVideoID', 'YouTube Video ID', '', 255) );
$imageField = new ImageUploadField( 'IntroductionVideoThumbnail', 'Video Thumbnail' );
$imageField->removeFolderSelection();
$imageField->setUploadFolder('ProductIntroductionVideo');
$fields->push( $imageField );
$fields->push( new LiteralField( 'literalfield_1', '<div>This image must be square image, and will be resized to 92x92</div><br>' ) );
$imageField = new ImageUploadField( 'IntroductionVideoImage', 'Video Image' );
$imageField->removeFolderSelection();
$imageField->setUploadFolder('ProductIntroductionVideo');
$fields->push( $imageField );
$fields->push( new LiteralField( 'literalfield_2', '<div>The image size must be 370x218</div><br>' ) );
return $fields;
}
}
class IntroductionVideoThumbnail_CustomImage extends Image {
function generateCustomImage($gd){
return $gd->resize(92, 92);
}
function generateBackendThumbnail($gd){
return $gd->resize(92, 92);
}
}
class IntroductionVideoImage_CustomImage extends Image {
function generateCustomImage($gd){
return $gd->resize(370, 218);
}
}
?>