Closed (duplicate)
Project:
D7 Media
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
17 Mar 2011 at 17:33 UTC
Updated:
4 Aug 2011 at 05:12 UTC
How do I change where the media files get uploaded to? Currently all the files get uploaded to the top level of my files directory. Ideally I'd like to create a new folder for each media type. Sorry if this has been covered before.
Comments
Comment #1
tomgf commentedI am having the same situation.
It could be good to have the possibility of pointing where these files should be going, like you do with other fields (at least when using the image widget).
Any suggestions?
Comment #2
Zachmo commentedsubscribing
Comment #3
guypaddock commentedSubscribing
Comment #4
kaptinfly commentedSo I've gotten around this problem by adding an image field to the content type and uploading all my images first. They go into the specified directory created in the field settings. Then I can go to the media library and pick a recently added image. You have to completely ignore the Upload button in the media module. This might get confusing to some people who have to add content.
Comment #5
tomgf commented@kaptinfly: you are right. This is a workaround but it will confuse some people… And from an usability perspective, it's not very good to have this extra step…
What I am thinking of is to create a module that will organize the files afterwards. It could easily check the table
file_managedand move all the files having an uri value likepublic://FILENAME.EXTto subdirectories, i.e. using the timestamp value from the same table.This could run on cron and move the files to this kind of structure:
In this case, this module won't interfere at all with the Media module and it could be removed afterwards when Media has a better way of organizing uploaded files…
What do you think about this idea?
Comment #6
dwalker51 commentedSounds great!!! I was thinking about the same....not sure how to do it, I haven't really gotten into drupal modules quite yet.
What I did find out is that yes...if you move the files around and rename them , create subdirectories, changing the link in file_managed will make them appear correctly when viewing the images, such as when using the media module.
for example here is a select from the table file_managed
In the last line I had created in the public directory a subdirectory called gallery
I moved the directory gallery to gallery2 (renamed)...and then changed in this table the uri field from gallery to gallery2.
That solves viewing with the media module
However all nodes that have been created with the original file link will still show a missing file.
I found that by looking in the filed_data_body table, content was saved there.
Here is the table
I found a test page i had created with the original file in gallery (entity_id was 116). Its link was still wrong so I did an sql update and then the image in gallery2 appeared on the test page
So it seems that you have to modify at least these two tables, questions I have are:
Are these the only tables that need to be modified?
Sounds like a script that goes through both tables looking for the respective file link shouldn't be too difficult?
At this point I am tempted to just wait and maybe make a file structure, have my users use that, and then just hope that some sort of file management module comes out or that media finally allows me to update and modify folders/filenames, most of the modules that might do this like webfm are a while away from version 7. http://drupal.org/project/webfm
Comment #7
tomgf commentedI don't think that you have to modify the field_data_body (or field_revision_body) if the files are inserted there using the filter [[media]]:
If you modify the location of the file in table file_managed – and clear the cache – the field_data_body will reflect this, as you are not modifying the fid.
I will try to start coding a module to do so as soon as I can…
Comment #8
JacobSingh commentedComment #9
rickmanelius commentedI agree. Throwing all the files in the top level of the files directory is very unappealing to me. But using something like post #5 above would be amazing.... so that we can organize it in the back end.
Comment #10
rodrigoaguilerasuscribe
Comment #11
dddbbb commentedSubscribing. I'd love to see this improved too. I think an optional year/month automated storage setup like the one suggested in #5 would be a smart move.
Comment #12
effulgentsia commented+1 to this feature request.
Comment #13
dddbbb commentedA clean up of existing files on install would also be great news for anyone already using this module that wants to take advantage of such a feature.
Comment #14
anavarreSubscribing
Comment #15
effulgentsia commentedMarked #1161420: Change file paths based on tokens a duplicate. There's also an issue in the FileField Paths project (#1161524: Integrate with the Media module) that could help with this.
Comment #16
damienmckennaSubscribing, given I opened the other two issues mentioned in #15 ;-)
Comment #17
rwohlebsubscribe
Comment #18
decipheredJust a quick note, as soon as I get back to FileField Paths, I will be making absolute certain that it works with Media, though as Media uses Fields, there is no reason it should require any extra work.
Comment #19
damienmckenna@Deciphered: that'll be awesome!
Comment #20
decipheredNo promises on time frame, current schedule is: Custom Formatters 7.x-2.x, Wysiwyg Fields 6.x-1.x/7.x-1.x then FileField Paths 7.x-2.x
Comment #21
yareckon commentedsub.
Comment #22
glottus commentedsubscribing
Comment #23
chiebert commentedSub
Comment #24
g76 commentedsub
Comment #25
joostvdl commentedsubscribe
From the WYSIWYG editor it is not possible to select an directory where to store the files/images.
Comment #26
aaron commentedsee also:
#1201920: Hide field and widget settings that the media widget cannot support
#1201924: Widget does not respect settings in file_field_instance_settings_form (uri scheme, directory, extensions, file size)
#1201930: Hide the title and alt settings for image fields if media widget is used
Comment #27
aaron commentedand #1201936: Move the media field to a non-required submodule, which points the way to a new paradigm :D
Comment #28
gusaus commentedWith #1166168: Expose a widget for filefield and imagefield, so that media browser can be used for them working, I'm able to create a subdirectory for each field. There's still a problem in that the media browser will only upload to whatever is selected as the default download method for the entire site.
#1069582: How to use an alternate stream wrapper when saving media files?
Comment #29
Pocketpain commentedsub
Comment #30
Niklas Fiekas commentedSubscribe.
Comment #31
JoshHamilton commentedSubscribe.
Comment #32
Poieo commentedSubscribing
Comment #33
kgrigsby@mac.com commentedSubscribe
Comment #34
montchr commentedsubscribe
Comment #35
dave reidI think this should be merged into #1201924: Widget does not respect settings in file_field_instance_settings_form (uri scheme, directory, extensions, file size) now that the Media field type is deprecated.
Comment #36
dave reid