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.

General Questions

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

Image Map


2 Posts   362 Views


19 September 2012 at 8:48pm (Last edited: 20 September 2012 2:44am), Community Member, 66 Posts


I'm having trouble with something and it's just occurred to me that it may be impossible to implement.

I want to create an imagefield that only allows the user to select existing images. I'm currently trying to implement a dropdown of images but I'm having trouble.

Here's what I've got so far.

$images = DataObject::get("Image", "ParentID = 5");
   $images->toDropdownMap("ID", "Image", $emptyString = "--select--");

$imageField = new DropdownField('Photo', 'Choose an image', $images);

I tried a treedropdownfield but I need a thumbnail of the image, not just the title.

I also tried this.

class OneFolderImageField extends ImageField {

   function __construct($name, $title, $value = null, $form = null, $rightTitle = null, $folderName = null) {
      $folder = Folder::findOrMake($folderName);
      $this->folderName = $folderName;
      parent::__construct($name, $title, $value = null, $form = null, $rightTitle = null, $folder->Name);

   public function EditFileForm() {
      $filter = create_function(
         '$item', '
         $folder = Folder::findOrMake(\''.$this->folderName.'\');
               (in_array("Image", ClassInfo::ancestry($item->ClassName)) && $item->ParentID == $folder->ID)
               (in_array("Folder", ClassInfo::ancestry($item->ClassName)) && $item->ID == $folder->ID)
      $form = parent::EditFileForm();
      return $form;


$imageField = new OfferImageField('Photo', 'Photo', 'Photo', $this, 'Test', $folderName);

But that didn't work as I thought it would.

Thanks in advance.


20 September 2012 at 2:43am (Last edited: 20 September 2012 2:43am), Community Member, 66 Posts


After many long hours of trying many different convoluted methods it turns out all I need to do to get rid of the upload from computer option was this.


I found it buried here

Works in 2.4.7