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, simon_w

[Solved] Image Thumbnails in Gridfield


Reply

23 Posts   6193 Views

Avatar
UndefinedOffset

5 July 2012 at 4:21am Community Member, 27 Posts

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

Avatar
jak

30 July 2012 at 12:07am Community Member, 46 Posts

This will be fixed in 3.0.1 (currently RC2).

Avatar
Futureweb

10 October 2012 at 5:19pm Community Member, 233 Posts

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:
[url]http://www.silverstriperesources.com/articles/silverstripe-3-0-2-grid-fields-with-thumbnails/[/url]

Avatar
neilcreagh

11 October 2012 at 12:58am Community Member, 94 Posts

Thank you!

Avatar
priithansen

19 October 2012 at 11:45am Community Member, 25 Posts

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

14 December 2012 at 1:33am Community Member, 6 Posts

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

29 April 2013 at 4:35pm Community Member, 21 Posts

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