Hi,

I tested imagefield 2 with the new token integration (wonderfull idea to avoid the creation of 99999 image field type just to separate path..), but there is one thing that annoy me.

I didn't see node token for example, the node type, to separate images of different node types into different destination folder, I saw some token for users, but not nodes.

It is a bug or a missing feature actually and it will be implemented ?

thanks

zmove

Comments

alippai’s picture

Please add taxonomy tokens too :)

zmove’s picture

Hmmm, any answer would be appreciated, just to know if I can use imagefield for my needs, or if I have to look for another module ?

thanks

zmove

jpetso’s picture

Version: 5.x-2.0-rc4 » 5.x-2.0-rc6

It's a missing feature, not sure if it can be implemented because when you initially create a node, imagefield doesn't know much of the required node data yet. The only thing we know for sure is the user who is logged in, which is why you can use user tokens. Maybe node tokens are doable as well (needs to be researched more in detail), but I imagine it'll take a while, if at all.

zmove’s picture

Hum, I see...

It seems that the images are uploaded in the right path when the node is created, not before (cause when you upload imagefield and, finally, don't submit the node, the images are not uploaded).

So, if the images are moved from the temp directory to the final directory on the node creation, maybe it's possible to get the node title ?

baja_tz’s picture

subscribe

baja_tz’s picture

I tried to add $node->nid to my file name, with this experimental code:

function imagefield_file_insert($node, &$file, $field) {
...
$file['filename'] = $node->nid . '_' . $file['filename']; // added line
 $filepath = file_create_path($widget_image_path) . '/' . $file['filename'];
...
}

and it works for now, i tested it just few times. Works with lightbox and views. I'm not sure is there some problem with this (security or some others), if not I think it's not problem to implement it through module. I suppose it would be possible to add another node variables and change path too.

dopry’s picture

Status: Active » Postponed

If you had done your research on this feature you wouldn't be asking these questions....

1) You cannot know the path/url to the image on node creation if you base it on a non-existent node, even though the image isn't saved to it's final location until the node is saved.

2) In Drupal 6 the file is save to it's final location on upload and not node save.

3) Node metadata, all but node id, is mutable over time... Leading to potentially broken or misleading token paths in the future. IE) it is recipe for inconsistency.

I'm postponing for later review... I'm pretty sure this is also a duplicate of a won't fixed feature request.

dopry’s picture

Status: Postponed » Closed (won't fix)

I'd prefer proper site-date tokens be added to token modules. Once files can be shared the node specific data will be even less usable.

mrfelton’s picture

would node creation date be possible? If it's new node, it'd just be todays date. Otherwise, the information would be stored in the node.