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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

ss 3.0.2 CMSThumbnail returns null


Go to End


2 Posts   672 Views

Avatar
longy

Community Member, 5 Posts

7 November 2012 at 1:23pm

Edited: 07/11/2012 1:52pm

I'm trying to show a thumbnail in summary gridfield.

static $has_many = array(	'Images' => 'Image');

static $summary_fields = array(
		'Title' => 'Title',
		'Thumb' => 'Thumb'
);

public function getThumb()
{
	if($this->Images()->count())
        {
			$image = $this->Images()->first();
			return $image->CMSThumbnail();
	}
	else return "No images.";	
}

$image contains the correct Image object, but CMSThumbnail returns null, why?

Maybe I found the problem, but i can't solve it.

$image->Filename returns assets/{imageName}

Images are uploaded in 'assets/upload', but Silverstripe looks for them in assets. Why?

Avatar
longy

Community Member, 5 Posts

8 November 2012 at 12:37am

sorry I did not read the documentation carefully, the problem is due to relation 'has_many' for images. Changed to 'many_many' and seems to work properly.