5102 Posts in 1520 Topics by 1116 members
| Go to End | ||
| Author | Topic: | 5186 Views |
-
Re: Adding multiple images to a page type

3 March 2010 at 11:05pm
Hello Ben_W,
Thank you again for your help.
$MyGalleryImage.SetSize(70,70) did not work under SilverStripe version 2.3.6 but does work under 2.4 beta.
Version 2.3.6 throws up a missing argument 1, which I think I've traced back to the cache output of the template which is the SSView.
In this the argument of (70, 70) does not appear to be part of the call to SetSize.I spent ages trying to get this to work, and may have to go with version 2.4. beta but its for a live site and I hope the stable version of 2.4 is around the corner.
Cheers
Chris -
Re: Adding multiple images to a page type

4 February 2011 at 5:00am
It's getting to the end of processing, but not uploading the image. What am I missing?
-
Re: Adding multiple images to a page type

14 February 2011 at 8:12pm Last edited: 14 February 2011 8:13pm
BigChris, sorry mate, did not get any notification email from the post, until it's been bumped. for what it's worth. ^_^ You may try create your own image class like the following:
class ImageGalleryPageImage extends DataObject {
static $db = array(
);
static $has_one = array(
'ParentImageGalleryPage' => 'ImageGalleryPage',
'GalleryImage' => 'ImageGalleryPageImage_CustomImage',
//'GalleryImage' => 'Image'
);function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new ImageField( 'GalleryImage', 'Gallery Image' ) );
$fields->push( new LiteralField( 'literalfield_1', '<div>For best result, use image size of 930x500.</div><br>' ) );
return $fields;
}public function getTooltipThumbnail() {return $this->GalleryImage()->BackendThumbnail();}
}class ImageGalleryPageImage_CustomImage extends Image {
function generateCustomImage($gd){
$gd->setQuality(85);
return $gd->resizeRatio(930, 500);
}
function generateCustomThumbnailImage($gd){
$gd->setQuality(85);
return $gd->paddedResize(98, 66, '#000000');
}
function generateBackendThumbnail($gd){
$gd->setQuality(85);
return $gd->resizeRatio(300, 300);
}
}Please take a note that instead of using default class 'Image', just use your custom image class
'GalleryImage' => 'ImageGalleryPageImage_CustomImage',
//'GalleryImage' => 'Image'then in the ss template, you may use it like this:
<% control ImageGalleryPageImages %>
<li>
<!--IMAGE-->
<div class="thumbnail">
<a href="$GalleryImage.CustomImage.URL" class="thumb">
<img src="$GalleryImage.CustomThumbnailImage.URL"<% if ImageTitle %> alt="$ImageTitle"<% end_if %> />
</a>
</div>
<div class="caption"></div>
<!--/IMAGE-->
</li>
<% end_control %>Hope it can still be useful, since we all need to maintain the old site. ^_^
-
Re: Adding multiple images to a page type

13 April 2011 at 3:10am
@ BigChris
For me, in 2.4,
<% control GalleryImages %>
$MyGalleryImage.CroppedImage(228,135)
<% end_control %>worked perfectly. which was absolutely wonderful. I love SS! (this is my first SS project)
| 5186 Views | ||
| Go to Top |



