Imagefield currently has token support for 'global' and 'user' tokens, but it'd be nice if it supported taxonomy tokens as well. Other modules (file path upload) provide this support, for example.

Comments

bsuttis’s picture

I believe I've gotten to a solution, although I very much doubt it's implemented as well as it could be.

What I did was go through the DRUPAL-5--2 imagefield.module, find the token_replace functions and any reference regarding tokens, removed the global $user checks, and replaced the 6 instances of user and $user with node and $node.

Seems to be working from the limited testing I've done. Having my path as files/[term], and adding an image to a node with a category of foo adds the image to files/foo.

I wouldn't attempt a path though as this removes the $user variables -- however in my case, I have no use for user folders.

Any advice is appreciated.

sun’s picture

Title: Have token support for Taxonomy » Taxonomy token support
Component: Miscellaneous » Code

Better title.

bfsworks’s picture

I tried this work around without success. I suggested in another thread that pathauto be used to set image paths.

yan’s picture

Great that token support is going to be included. I'm waiting a while for that already. Thanks!

One thing though: I was hoping to be able to use [yyyy] and [mm] for year and month, but it doesn't work. Instead there are a couple of date functions ([site-date][log-date][date-in-tz][account-edit]) but they give out really weird folders like

/Thu, 12/13/2007 - 17:45/

I'd be great if more usability was added to this, providing tokens that make more sense for paths.

dopry’s picture

Version: 5.x-2.x-dev » 6.x-3.x-dev

@yan, post your request in the token module issue queue.

I'd still love to expand the token support, but there are some issues that need to be figured out.

1) Should we wait until node submit to save all the file information (This won't be possible in D6 as the file workflow changes), but we could update file on new node insert.

2) Should we update the filepaths/url when tokens change on node updates? This causes link rot.

Lets slate this as a 2.1 feature.

yan’s picture

Status: Closed (won't fix) » Active

thanks for your reply, dopry

@yan, post your request in the token module issue queue.

I posted the issue here because I don't think it's a token issue. Right now I'm using the File attachments field to have pictures stick to a node (afterwords I manipulate them using imagecache). There I'm using the upload path module which works with the token module. There are no problems using [yyyy] and [mm], it uses the actual date when the node is published. If you attach an image to an older node (i.e. to a node from a month that finished already) the node creation date is used. This seems to be a perfect solution for me. I was wondering why file attachments & upload path & token do work this way while imagefield & token don't.

dopry’s picture

Status: Active » Closed (won't fix)

@yan, for the reasons outlined above... I don't have a created date/time for the node at the time the file is created... The file is saved to it's destination before the node is created. I have nightmares about preview paths and final paths differing... You know breakage...

I've thought about this more and I'm simply not going to fix this issue. There is a patch in the token issue queue for site-date-[Y,y,M,mm,dd] etc tokens that use the site's unixtime to generate the token values.. Review and get eaton to commit.

yan’s picture

I think I see what you're saying, but I still don't understand what I wrote before:

I was wondering why file attachments & upload path & token do work this way while imagefield & token don't.

Status: Active » Closed (won't fix)