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.

General Questions /

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

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

[Solved] Image Thumbnails in Gridfield


Go to End
Reply


23 Posts   8294 Views

Avatar
UndefinedOffset

Community Member, 30 Posts

5 July 2012 at 4:21am

Doesn't look to be, the last commit to the effected file was a month ago.

Avatar
jak

Community Member, 46 Posts

30 July 2012 at 12:07am

This will be fixed in 3.0.1 (currently RC2).

Avatar
Futureweb

Community Member, 243 Posts

10 October 2012 at 5:19pm

seems that in silverstripe 3.0.2 it works if you use

public function getThumbnail() {
return $this->Image()->CMSThumbnail();
}

i just made a quick tutorial about it here too:
http://www.silverstriperesources.com/articles/silverstripe-3-0-2-grid-fields-with-thumbnails/

Avatar
neilcreagh

Community Member, 107 Posts

11 October 2012 at 12:58am

Thank you!

Avatar
priithansen

Community Member, 25 Posts

19 October 2012 at 11:45am

For some reason the Futuraweb solution doesn't seem to work with ModelAdmins gridfield.
Have to use this nasty thing

<?php
class SliderImage extends DataObject {

	static $db = array(
		'Description' => 'Varchar(255)'
		);

	static $has_one = array(
		'Image' => 'Image'
		);

	static $summary_fields = array(
		'ImageNice' => 'CustomPicTitle',
		'DescriptionNice' => 'CustomDescTitle'
		);

	static $casting = array(
		'ImageNice' => 'HTMLText',
		'DescriptionNice' => 'Varchar'
	);
	
	public function getImageNice() {
		return $this->Image()->CMSThumbnail();
	}
	public function getDescriptionNice() {
		return $this->Description;
	}
}

Otherwise I get an error "Unable to traverse to related object field [Thumbnail] on [SliderImage]"
And using the casting for Description is the only way the gridfield columns pick up my custom titles aswell.

Avatar
arnhoe

Community Member, 6 Posts

14 December 2012 at 1:33am

And using the casting for Description is the only way the gridfield columns pick up my custom titles aswell.

You can no longer change field names through $summary_fields. You should use $field_labels, "Title" => "Titel"

Avatar
RobboDev

Community Member, 22 Posts

29 April 2013 at 4:35pm

I've just fixed the problem when trying to add thumbnails to model admin in SS3

If you're getting "Can't traverse to [image something] on your object"

then you just need to add searchable fields, and it fixes it!

Something like this: (use your field names obviously)

static $searchable_fields = array(
'ID',
'Name'
);

Rob Clarkson

Go to Top