Hello,

It would be nice if the default folder that IMCE launches into when you click 'Open File Browser' matched the configured upload location for the filefield. For example suppose you had a filefield on a content type called "Blog" and it's configured to upload the file to "blog/images". It makes sense to me to have IMCE open directly into that folder rather than into the last folder the user opened.

Patch to follow!

drclaw

Comments

drclaw’s picture

Status: Active » Needs review
StatusFileSize
new2.68 KB

Here's a patch that adds the functionality described above. All it does is check the #upload_location property of the filefield element and add it to the javascript settings. Then when imce is launched in imce_filefield.js we add the directory to the imce path.

This is sort of a quick fix to show that it's at least easy to tell IMCE to open a specific default directory. It's possible we may want to make this something that is configurable on a field by field basis or on a global level. I'll wait for some feedback maybe before revising?

Thanks!
drclaw

drclaw’s picture

Title: Default Directory to match Filefield's upload location » Default IMCE directory option
Issue summary: View changes
StatusFileSize
new3.31 KB

Hello again,

I'm thinking it might be better to make this it's own setting? That way it will play nice with other modules like filefield_paths that override the core upload directory destination field. Patch attached!

Thanks!
drclaw

drclaw’s picture

StatusFileSize
new5.48 KB

Sorry, wrong diff on that last patch! By bad!

marc delay’s picture

Status: Needs review » Reviewed & tested by the community

Thanks this is very helpful for our use case.
We have an ftp folder where we place files to be added to our site and the editors who do that were getting confused about how to get to the ftp folder from the document root.

We have testing this patch and things are working well for us.

scott_earnest’s picture

Great patch drclaw - thank you very much for it.

I was running into an issue where I had different fields that were using the IMCE Filebrowser on an edit page. The settings would only take the default directory of the first field rendered on the edit form, and would not set the directory on a field specific level.

I made adjustments to imce_filefield.inc, moving the "dir" into the _imce_filefield_field_pre_render() function. Then in the imce_filefield.js file I moved the setting of the "dir" inside the fields loop.

Sorry I am not great at patch writing but hopefully these suggestions will help.

scott_earnest’s picture

scottatdrake’s picture

That patch wasn't applying for me, though I'm not sure why. I've re-rolled against the current code and uploaded a new patch file. Never mind. Operator error. The existing patch works great for me.

scottatdrake’s picture