Jump to:

22972 Posts in 11596 Topics by 2824 members

General Questions

SilverStripe Forums » General Questions » No thumbnail - Attach from files pop up.

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: 341 Views
  • James Bolitho
    Avatar
    Community Member
    33 Posts

    No thumbnail - Attach from files pop up. Link to this post

    Hi,

    I am just wondering if I am missing something but I have noticed that when using the 'UploadField' in SS 3.0.3 to attach image files to a DataObject if I select 'Attach a file' - 'from files', in the resulting pop up that displays all the files available to be selected there is no thumbnail displayed next to the name of the file unlike under the files tab.

    I am not sure if I am being dumb and missing a step when constructing my object but below is a snippet from my Object relating to the upload field:

    ....
    $fields = new FieldList();
          
    $fields->push($thumbField = new UploadField('GalleryImage', 'Gallery Image'));
    $thumbField->allowedExtensions = array('jpg', 'png', 'gif');
    $thumbField->setFolderName('Uploads/gallery-images');
    ....

    I hope that explanation makes sense. Any ideas would be appreciated.

    Thanks,

    James

    Edit - solution found

    Ok after some looking around the core files I found a solution. I edited the UploadField.php file in framework/forms folder. Added the following lines after line 975:

    $columns = $fileField->getConfig()->getComponentByType('GridFieldDataColumns');
          
    $columns->setDisplayFields(array(
    'StripThumbnail' => '',
    'Name' => 'Name',
    'Title' => 'Title'
    ));

    Not keen on using core hacks but this at least gets a thumbnail of an image displaying (well it has for me anyway). If anyone has a better solution I am all ears .

    Cheers,

    James

    341 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.