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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

No thumbnail - Attach from files pop up.


Go to End


1250 Views

Avatar
James Bolitho

Community Member, 33 Posts

29 November 2012 at 4:37am

Edited: 05/12/2012 11:48pm

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