【问题标题】:ImageField Select DirectoryImageField 选择目录
【发布时间】:2012-09-06 15:15:06
【问题描述】:

我正在使用 SilverStripe 2.4.7,我想知道在使用 ImageField 时是否有办法限制用户从 CMS 上的文件夹中选择图像(不允许他们从桌面上传)?

到目前为止,我还没有发现任何东西让我相信这是可能的。

编辑

我找到了这个,但我不知道如何应用它。我猜我需要在 imagefield 变量上调用它。

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

【问题讨论】:

    标签: silverstripe


    【解决方案1】:

    您始终可以使用 TreeDropdownField 代替 ImageField。这将允许用户从下拉列表中浏览和选择文件。

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

    您还可以使用...将选择选项限制在特定文件夹中

    $filefield->setTreeBaseID($idOfFolder);
    

    我想唯一的缺点是用户在附加图像时将无法看到缩略图,就像使用 ImageField 一样...另一个选项是子类化 ImageField 并查看您能做什么删除“从您的计算机”单选选项。

    【讨论】:

    • 好建议,谢谢。我从没想过TreeDropDownField。我想我会先用有意义的名字试试。
    • TreeDropdownField 对我不起作用。有人用过 ImageField 的 EditFileForm 方法吗?
    猜你喜欢
    • 2015-02-16
    • 1970-01-01
    • 1970-01-01
    • 2013-02-19
    • 1970-01-01
    • 1970-01-01
    • 2019-12-15
    • 2015-08-05
    • 1970-01-01
    相关资源
    最近更新 更多