Jump to:

22992 Posts in 11842 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » [Solved] Image Thumbnails in Gridfield

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

Page: 1 2 3
Go to End
Author Topic: 5194 Views
  • UndefinedOffset
    Avatar
    Community Member
    27 Posts

    Re: [Solved] Image Thumbnails in Gridfield Link to this post

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

  • jak
    Avatar
    Community Member
    46 Posts

    Re: [Solved] Image Thumbnails in Gridfield Link to this post

    This will be fixed in 3.0.1 (currently RC2).

  • Futureweb
    Avatar
    Community Member
    232 Posts

    Re: [Solved] Image Thumbnails in Gridfield Link to this post

    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/

  • neilcreagh
    Avatar
    Community Member
    88 Posts

    Re: [Solved] Image Thumbnails in Gridfield Link to this post

    Thank you!

  • priithansen
    Avatar
    Community Member
    25 Posts

    Re: [Solved] Image Thumbnails in Gridfield Link to this post

    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.

  • arnhoe
    Avatar
    Community Member
    6 Posts

    Re: [Solved] Image Thumbnails in Gridfield Link to this post

    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"

  • RobboDev
    Avatar
    Community Member
    20 Posts

    Re: [Solved] Image Thumbnails in Gridfield Link to this post

    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

    5194 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.