0

I have a node for a photo. I want to know what is the best why to define the file path for the images. The images will be user submitted.

Ideally, I would have liked the path be sites/default/files/photo/[node-reference:NID] so that each node would have all the image nodes associated with it in their own folder. This would make it easier to migrate the images since not only in the database but also in the file system would describe which images belong to which. Because the referenced node isn't available for the Tokens module I need to come up with a different strategy.

I have considered things like user sites/default/files/photo to dump all the images into one folder which might become a mess over time or sites/default/files/photo/[user id] so that each user's images are in separate containers. I don't know what the benefit of that would be.

I'm also thinking about creating a name convention for each image to that it has the node reference NID and user name in code. Is it worth the effort?

I'm looking at the image scr attributes on websites like grammy.com and examiner.com to see how they set it up. It looks like the examiner.com uses a hash to name the image.

Does anybody have any ideas on how to do this?

1 Answer 1

2

Since Token does not yet have support for field tokens, I would choose a temporary convention that makes sense to you. Once that feature is added, you can use FieldField Paths to reorganize your files.

3
  • There are quite a few bugs at this time including some with PHP 5.3 so I haven't been able to get it to work. Perhaps, when they get an alpha or beta version I will revisit the Field Paths module. How does having all the files in one folder effect performance? I know it's difficult to open a folder with 20,000 image files in it.
    – Adam S
    May 15, 2011 at 20:21
  • I would imagine that FileField Paths will be much better off by the time per-field tokens are added. I would suggesting splitting them up by Node id, and then later you can reorganize by reference Nid. May 15, 2011 at 22:30
  • I need a way to keep track of images so when the Media module reaches maturity I can easily port all the images in an upgrade. Using FileField Paths module I set the file path to photo/[date:custom:Y-m] while converting to lower case and file name to [node:field-photo-reference:nid]-[user:uid]-[file:ffp:onlyname:original].[file:ffp:extension:original]. This means that the first part of the images file name is the nid of the reference node. Very cool. You get a check.
    – Adam S
    May 16, 2011 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.