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

UploadField thumbnails?


Go to End


2 Posts   1246 Views

Avatar
kylehudson00

Community Member, 22 Posts

8 March 2013 at 8:23pm

Hi All, as per this tutorial:

http://doc.silverstripe.org/framework/en/trunk/tutorials/2-extending-a-basic-site

I've included an image field in one of my custom page types. However, when one clicks "Attach a file" -> "From files", there are no thumbnails in the list view. Also, UploadField seems to automatically create an 'Upload' folder, which is not something that I want.

So, my questions are:

1) How can I show thumbnails when users are using UploadField to attach images that already exist in the assets folder
2) How can I stop UploadField creating an "Uploads" folder? Further, can I set UploadField to default to a specific subfolder in assets?

Cheers,
Kyle

Avatar
socks

Community Member, 191 Posts

16 March 2013 at 1:27pm

Edited: 16/03/2013 1:27pm

Think the Uploads folder always exists by default. See if setFolderName below helps.

function getCMSFields() {
      $fields = parent::getCMSFields();

      // Image
      $imageField = new UploadField('TeamMemberImage','Team Member Image');
      $imageField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png'));
      $imageField->setConfig('allowedMaxFileNumber', 1);
      $imageField->setFolderName('Team-Member-Photos'); 
   
      // Add
      $fields->addFieldToTab('Root.Images', $imageField);

      return $fields;
   }