Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Adding multiple images to a page type


Go to End


12 Posts   11479 Views

Avatar
BigChris

Community Member, 63 Posts

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

Avatar
Usability Counts

Community Member, 5 Posts

4 February 2011 at 5:00am

It's getting to the end of processing, but not uploading the image. What am I missing?

Avatar
Ben_W

Community Member, 80 Posts

14 February 2011 at 8:12pm

Edited: 14/02/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. ^_^

Avatar
liece

Community Member, 9 Posts

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)

Go to Top