Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Image Map

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: 353 Views
  • Stef87
    Community Member
    66 Posts

    Image Map Link to this post


    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.

  • Stef87
    Community Member
    66 Posts

    Re: Image Map Link to this post


    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 http://api.silverstripe.org/2.4/forms/fields-files/FileIFrameField.html#methodsetCanUploadNewFile

    Works in 2.4.7

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.