Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Would it possible to specify directory paths for media to be stored as they are uploaded rather than being dropped into the directory designated by the Public file system path?
Also, is there a way that new media can be named when it's imported, so that the detail view's URL path can use it's name, rather than a number set by Media Gallery?
Comments
Comment #1
petervd CreditAttribution: petervd commentedA quick solution I use on my site:
Step 1. In file modules/media/media.pages.inc - function function media_add_upload (line 178) - add lines between 'pvd' comment
$form['upload'] = array(
'#type' => 'file',
'#title' => t('Upload a new file'),
'#description' => theme('file_upload_help', array('description' => '', 'upload_validators' => $validators)),
'#upload_validators' => $validators,
);
//pvd------------------------------------
$form['directory'] = array(
'#type' => 'textfield',
'#title' => t('Directory'),
'#description' => t('Enter a directory path where to store the image e.g. birds/europe/ as path (make sure to specify closing /).'),
'#default_value' => '',
);
//pvd------------------------------------
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
Step 2. In file modules/media/media.pages.inc - function function media_add_upload_submit (around line 245) - add lines between 'pvd' comment
function media_add_upload_submit($form, &$form_state) {
$scheme = variable_get('file_default_scheme', 'public') . '://';
//pvd------------------------------------
$scheme = $scheme . $form_state['values']['directory'];
//pvd------------------------------------
$file = $form_state['values']['upload'];
Step 3: Probably do the same in function media_add_upload_multiple_submit
function media_add_upload_multiple_submit($form, &$form_state) {
$scheme = variable_get('file_default_scheme', 'public') . '://';
//pvd------------------------------------
$scheme = $scheme . $form_state['values']['directory'];
//pvd------------------------------------
$saved_files = array();
Beware: the directory has to exist under your default file upload place. No checking is done in this simple solution.
Dare devils can always patch a mistake in the path directly in the database table 'file_managed'
hope this helps
Comment #2
Vasu CreditAttribution: Vasu commented+1
Comment #3
Ghostthinker CreditAttribution: Ghostthinker commented@maintainer Please tell if you need any help with that feature because it would really great to have album pics aggregated in a folder.
Comment #4
TripX CreditAttribution: TripX commentedI also think that this would be good instead of just 1 folder with all pictures.
+1
Comment #5
kgrigsby@mac.com CreditAttribution: kgrigsby@mac.com commentedThis is the only feature I need before using this module.
Comment #6
TripX CreditAttribution: TripX commentedComment #7
sanmikele CreditAttribution: sanmikele commented+1. This would definitely be a nice and useful feature.
Comment #8
kifuzzy CreditAttribution: kifuzzy commentedsign
Comment #9
totap CreditAttribution: totap commentedYes separate directory for each gallery would be very good.
Comment #10
b_ruben CreditAttribution: b_ruben commentedI would like to see this feature, too. Using default directory makes a mess of images, if you have a lot of galleries.
Comment #11
jczuo CreditAttribution: jczuo commentedsub
Comment #12
Poieo CreditAttribution: Poieo commentedsubscribing
Comment #13
tamsoftware CreditAttribution: tamsoftware commentedsub
Comment #14
greggus-1 CreditAttribution: greggus-1 commentedsubscribing
Comment #15
paulkras CreditAttribution: paulkras commentedThank you petervd, it is a good quick temp solution for some small galleries. I've tried it works good when you need to upload one or a few images. If you upload hundreds or thousands images then adding them one by one is too time consuming. The Library does not see this folder with the new path but only you add to the image Library as one set. If you have 10 000 pics it is not easy to work with them from one virtual folder (the Library). The module itself is very good, but absence of the folders feature and reusing them stops it from using for bigger galleries.
Comment #16
Starminder CreditAttribution: Starminder commented+1, I put a similar request here: http://drupal.org/node/1239624 to use tokens to specify the path.
This is an absolute showstopper for any live site. Putting all the image files in any one main directory is just asking for trouble long term.
Comment #17
Starminder CreditAttribution: Starminder commentedComment #18
Andrea C CreditAttribution: Andrea C commentedSubscribe
Comment #19
wipeout_dude CreditAttribution: wipeout_dude commentedWould love this feature as well..
I put up two galleries a month with about 100 photos each.. You can see how quickly the directory would fill up and become a nightmare to manage..
Comment #20
BramVanroy CreditAttribution: BramVanroy commented+1 It becomes hard to find a photograph when all the names are something like HP12448698
Comment #21
dgeraets CreditAttribution: dgeraets commentedThe first part of this issue (specifying upload paths) is a dup of #1201924: Widget does not respect settings in file_field_instance_settings_form (uri scheme, directory, extensions, file size).
Comment #22
helmo CreditAttribution: helmo commentedThe sandbox module suggested in #1201924: Widget does not respect settings in file_field_instance_settings_form (uri scheme, directory, extensions, file size) (Media upload directory) seems to present a config option where ALL images that are handled my the media module should go.
This is better then piling all media in the default files location(public://).
But I think the original poster was looking for a sub-directory per gallery.
If you have 10 galleries and 100 images each then separate folders make sense. When you handle 10,000 images it's a must.
Comment #23
scampbell70 CreditAttribution: scampbell70 commentedI would also love to see this feature added I also create two or three new galleries each month with over 100's in each gallery. I have somewhere in the range of 10,000 images now and I really need a way to have each gallery go into its own folder. What makes it even more critical for me to have this ability is that 99% of the photos uploaded come from users on the front end.
@helmo other then that sandbox module is there any other way to accomplish this?
Comment #24
Taxoman CreditAttribution: Taxoman commentedComment #25
Starminder CreditAttribution: Starminder commentedMoving back to critical, this one is a showstopper. The quickest fix would be to use tokens allowing the admin to determine where files should be stored and if subdirectories should be used. If you disagree, then you've never exceeded the capability of ftp to view files in a single directory. I have and it sucks. Please fix this, there are multiple threads regarding this very same issue. Thanks.
Comment #26
scampbell70 CreditAttribution: scampbell70 commentedI am also moving this to critical, I am choosing to go ahead and deploy this on my live site but I will continue to look for alternative modules to replace it with unless their is a fix to allow uploading to specific directories for each gallery. This really is a showstopper and the only major downside to this otherwise awesome module.
Comment #27
helmo CreditAttribution: helmo commentedA related request is posted under: #1239624: Ability to use tokens for file storage
The there suggested use of tokens could be a good enhancement for the code from #1
That way maybe the default directory name could be deduced from the Gallery name.... ?
Another issue that might be useful to relate to this discussion: #1037002: New feature: Gallery containers
Comment #28
timprotech CreditAttribution: timprotech commentedSubscribing. Major show-stopper!
Comment #29
scampbell70 CreditAttribution: scampbell70 commentedcould something like http://drupal.org/project/filefield_paths be added to allow directories to be specified?
Comment #30
helmo CreditAttribution: helmo commentedI've looked into filefield_paths last week, in some issue there was mention about support for the media module.
But all I could find was related to the 'file' field not the 'Multimedia asset' field which is used by media_gallery.
But then I came across this #974958: More settings for Multimedia asset field, where Dave Reid mentions in #1 that the 'Multimedia asset' filed is deprecated. Note sure what his means for the media_gallery module...
I've opened #1391332: Support file field as well as deprecated media asset field to investigate.
Comment #31
scampbell70 CreditAttribution: scampbell70 commentedThank you for looking into that helmo. To be honest at this point I am considering paying a module developer to just write me a photo gallery module that functions like media_gallery module but has the ability to specify the upload directory. The inability to control the photo upload is the only thing preventing me from launching this site and the gallery is basically the second biggest reason for the site to even exist, so it is a very key area to not have working right. I was going to pay someone to just add the functionality to this module and give the code back to the community but now with its future possibly in question I am not sure how wise that would be.
Comment #32
helmo CreditAttribution: helmo commentedI've updated #1391332: Support file field as well as deprecated media asset field
Media 2.x is moving to the file field, which probably also solves this issue.
Comment #33
scampbell70 CreditAttribution: scampbell70 commentedso once it moves to the media field we will be able to specify directory paths natively? Will this occur in 7 or be a drupal 8 thing?
Comment #34
helmo CreditAttribution: helmo commentedI sure hope that media 2.x will be a 7.x thing...
But as that is still a moving target it might work better for you to get it fixed in 1.x first
Comment #35
Starminder CreditAttribution: Starminder commentedFor me, there's no way in hell I'm even turning this module on in production without it. I've suffered the consequences once already, and they are far too great. Once a the file path has been exceeded you can't work with it at all and it only gets worse from there. Knowing full well my site and user community can bring it past that point - I'm just not going there again. MUST MUST MUST be able to determine the storage directories (plural) for this stuff prior to implementation. Personally I think tokens are the best way to go and likely the easiest to implement as well.
For me, this module just does not work without this necessary "feature". I refuse to implement it without some way to avoid pig-piling all images in a single directory. It's avoidable. It's a freaking NIGHTMARE. Not going there again. Please please please???
Comment #36
webadpro CreditAttribution: webadpro commentedSo guys, whats the plan here?
Comment #37
sachbearbeiter CreditAttribution: sachbearbeiter commented#35 agree completely ...
Comment #38
smartinm CreditAttribution: smartinm commentedI wanted to announce a new module which provides this functionality (galleries root directory and sub-directory per gallery with tokens supports) and more features/improvements should be coming soon:
http://drupal.org/project/media_gallery_extra
Please notice that this module is still in development stage and is subject to major changes. I discourage using it in production site but and I'm planning a release as soon as it will be more stable.
Any feedback is welcome.
Comment #39
lsolesen CreditAttribution: lsolesen commented@smartinm Does your module solve this issue? Could your module be merged into media_gallery or does it need to be its own thing?
Comment #40
lsolesen CreditAttribution: lsolesen commentedThis is hardly a critical as there is no data-loss, but it is a much wanted feature.
Comment #41
Andrea C CreditAttribution: Andrea C commentedDoes anyone tested successfully the Media Gallery Extra module?
On April 5 smartinm wrote
and the dev release is still updated on the same date.
Also this issue #1558560: Make media_gallery_extra work with media-7.x-2.x branch doesn't push me to use the module ...
Comment #42
jonloh CreditAttribution: jonloh commentedI've tested it out. The main feature I wanted was to have a defined file path for the Media Gallery, which is currently perfectly.
If you wish to have a custom defined path for your gallery images, please use Media Gallery Extra module.
Comment #43
Stephen Winters CreditAttribution: Stephen Winters commentedHas anything further been done in being able to specify the directory path for the media gallery module?
Best Wishes,
Stephen
Comment #44
lsolesen CreditAttribution: lsolesen commented@Stephen Winters You should not ask new questions in an existing issue. You are more than welcome to open new issues.
Regarding the implementation, @smartimn promised to help out #1516168: [META] Upcoming features and improvements and will when he got the time.
Comment #45
ivnish CreditAttribution: ivnish commented