1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?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('VideoName', 'Video Name', '', 255) );
        $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);
	}
}
?>