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

A 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

+1

@maintainer Please tell if you need any help with that feature because it would really great to have album pics aggregated in a folder.

I also think that this would be good instead of just 1 folder with all pictures.
+1

This is the only feature I need before using this module.

Version:7.x-1.0-beta4» 7.x-1.0-beta6

+1. This would definitely be a nice and useful feature.

sign

Yes separate directory for each gallery would be very good.

I would like to see this feature, too. Using default directory makes a mess of images, if you have a lot of galleries.

sub

subscribing

sub

subscribing

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

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

Priority:Normal» Critical

Subscribe

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

+1 It becomes hard to find a photograph when all the names are something like HP12448698

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

I 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?

Version:7.x-1.0-beta6» 7.x-1.x-dev
Component:User interface» Code
Priority:Critical» Major

Priority:Major» Critical

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

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

A 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

Subscribing. Major show-stopper!

could something like http://drupal.org/project/filefield_paths be added to allow directories to be specified?

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

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

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

so 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?

I 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

For 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???

So guys, whats the plan here?

#35 agree completely ...

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

@smartinm Does your module solve this issue? Could your module be merged into media_gallery or does it need to be its own thing?

Priority:Critical» Normal

This is hardly a critical as there is no data-loss, but it is a much wanted feature.

Does anyone tested successfully the Media Gallery Extra module?
On April 5 smartinm wrote

I discourage using it in production site

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

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

Has anything further been done in being able to specify the directory path for the media gallery module?

Best Wishes,
Stephen

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