MillyMonster
MillyMonster

Reputation: 556

ImageField Select Directory

I'm using SilverStripe 2.4.7 and I'm wondering if there is a way to limit the user to selecting an image from a folder on the CMS (not allowing them to upload from their desktop) when using an ImageField?

I haven't found anything so far that leads me to believe that it is even possible.

Edit

I found this but I'm not sure how to apply it. I'm guessing that I need to call it on the imagefield variable.

http://api.silverstripe.org/2.4/forms/fields-files/ImageField.html#methodEditFileForm

Upvotes: 0

Views: 263

Answers (1)

LiveSource
LiveSource

Reputation: 6409

You could always use a TreeDropdownField instead of ImageField. This would allow the user to browse and select a file from a dropdown list.

$filefield = new TreeDropdownField('MyFileID', 'Select a file', 'File');

you could also restrict the selection options to a particular folder using...

$filefield->setTreeBaseID($idOfFolder);

I guess the only drawback with that is the user wouldn't be able to see thumbnail when the image is attached, like they would with an ImageField... the other option would be to subclass the ImageField and see what you could do to remove the "From your computer" radio option.

Upvotes: 1

Related Questions