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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Cannot set custom folder for ImageField


Go to End


17 Posts   8439 Views

Avatar
wmk

Community Member, 87 Posts

19 August 2009 at 9:42pm

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

Avatar
blair

Community Member, 9 Posts

20 August 2009 at 9:11am

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.

Avatar
theAlien

Community Member, 131 Posts

8 January 2010 at 2:20pm

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.

Avatar
dacar

Community Member, 173 Posts

15 January 2010 at 4:23am

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...

Avatar
Fuzz10

Community Member, 791 Posts

21 April 2010 at 2:24am

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 ?

Avatar
Carbon Crayon

Community Member, 598 Posts

23 April 2010 at 9:34am

Edited: 23/04/2010 9:36am

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

Avatar
Fuzz10

Community Member, 791 Posts

23 April 2010 at 8:50pm

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 ?

Avatar
Carbon Crayon

Community Member, 598 Posts

23 April 2010 at 9:49pm

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.