Jump to:

23451 Posts in 18899 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » ss 3.0.2 CMSThumbnail returns null

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
Go to End
Author Topic: 373 Views
  • longy
    Avatar
    Community Member
    5 Posts

    ss 3.0.2 CMSThumbnail returns null Link to this post

    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?

  • longy
    Avatar
    Community Member
    5 Posts

    Re: ss 3.0.2 CMSThumbnail returns null Link to this post

    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.

    373 Views
Page: 1
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.