Jump to:

23480 Posts in 18951 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Cannot set custom folder for ImageField

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 2 3
Go to End
Author Topic: 5367 Views
  • wmk
    Avatar
    Community Member
    45 Posts

    Re: Cannot set custom folder for ImageField Link to this post

    Hi blair,

    any info on why it didn't make it into 2.3.3 or how we can make it work in 2.3.3? which files to patch / replace?

    thanks,

    wmk

  • blair
    Avatar
    Community Member
    9 Posts

    Re: Cannot set custom folder for ImageField Link to this post

    Hi wmk,

    Sounds like the fix will be included in 2.4.0.

    I have asked for a patch from Silverstripe as this is something we really need to work. Will let you know once I hear from them.

    Blair.

  • theAlien
    Avatar
    Community Member
    131 Posts

    Re: Cannot set custom folder for ImageField Link to this post

    I wrote a SS2.3.x-module with a temporate fix that can be downloaded here.

    Of course you have to do some rewriting as soon as you start updating your productionsites.

  • dacar
    Avatar
    Community Member
    168 Posts

    Re: Cannot set custom folder for ImageField Link to this post

    Hi, if you have a look at the changelog from 2.3.4 you will not find the bugfix for the image-upload-folder-problem. Could anybody publish the bugfix for those who need it importantly?

    Carsten...

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: Cannot set custom folder for ImageField Link to this post

    In 2.4 , this problem has been fixed.

    BUT, it would be _really_ nice if you could tell the image-field "from the file store" dropdown to go to a specific folder as well.. (usecase : client uploads a shitload of assets by FTP , reloads the assets , and needs to link those images to dataobjects or pages)..

    Is this possible ?

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Cannot set custom folder for ImageField Link to this post

    Hi Fuzz10,

    I actually had a play around with this and have a slightly hacked custom field working with this option. Basically there is no way to do this with the standard file fields, however the treeDropdownField which is used to select the folder does have a argument to define the starting ID for the tree, so basically I have created a custom field with a 7th argument which is the name of the folder you want to start with. However, it does mean that you can't make your way back above this folder, so it's not particularly flexible, though that could be a good thing depending on the use case.

    Anyway here is the code for the CustomFileField: http://pastie.org/930505

    To use it simply supply the folder you want to set as the selected one as the final argument like so:

    new CustomFileField('FieldName', 'Title', Null, Null, Null, 'UploadFolder', 'SelectedFolder');

    Note, if the folder does not exist it will default to root.

    Also I did this pretty quickly so it might not be totally sound, and have only tested this on 2.4 RC1.

    Let me know if works for you

    Aram

    www.SSBits.com - SilverStripe tutorials, tips and other bits

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: Cannot set custom folder for ImageField Link to this post

    Aram,

    Thanks a bundle !! I'll play around with this over the next weekend !!!

    I think this would be a very nice addition to the core CMS , no ?

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Cannot set custom folder for ImageField Link to this post

    Yea would definately be useful as a core feature and seems like all the basics are there to implement it, though not sure my code would be good enough! lol

    Aram

    www.SSBits.com - SilverStripe tutorials, tips and other bits.

    5367 Views
Page: 1 2 3
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.