Per original discussion with Deciphered, make the module support nid, title, timestamp tokens.

The functionality that sets ImageField Tokens apart is that it allows for Node tokens, which require the tokens to be processed after the node has been processed as certain Node tokens aren't available others (NID, Title, etc, can't be know until the Node is saved).

Current code runs token_replace() during node_save() in hook_field_attach_presave(). The hook_filefield_paths_process_file() in the D7 filefield_paths.module is run during hook_node_update(), so you've got to call field_attach_update() twice.

Functionality could be implemented using hook_field_storage_pre_insert() and hook_field_storage_pre_update(); the functions run after drupal_write_record('node', $node); and drupal_write_record('node', $node, 'nid'); but before the field data is saved. Neither file.field.inc or image.field.inc implement hook_field_storage_pre_insert/update(). Reference: http://api.drupal.org/api/drupal/modules--field--field.attach.inc/functi...

Comments

colan’s picture