For any large collection of images, storing all the files in a single directory becomes unworkable.

How (through the API) can I make the Image module or the Image Attach module store an uploaded image in a location other than the default image path?

In my case, I need to choose a subdirectory of the default image directory based on a taxonomic term that the user has set in the node to which the picture is attached, and the value of a field in the user's profile.

Comments

ansorg’s picture

in theory this module http://drupal.org/project/uploadpath should do what you (and I) want.

In reality, #256210: _image_build_derivatives should leave files in their original location works against the specified uploadpath and puts the images back into /files/images :( see also #257871: conflict with image module: defined path gets ignored (overwritten)

Until now I seemed to be the only one to care about this, no response yet to my bug reports. I tried to modify the image.module myself but got it not working for all possible upload methods :(

Jens

Hetta’s picture

Status: Active » Closed (duplicate)
orthoducks’s picture

I've read that thread, although I didn't understand everything in the comments. The original proposal is not the same as what I asked about: it is to rename the uploaded image to reflect the owning node ID. That's also a way of organizing images, but it's a completely different way. It would eliminate the risk of conflicting filenames if no node has more than one image, but in my opinion, its usefulness would be much more limited.