Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
In Drupal 7, while attempting to specify the "File directory" option as "fields/field_foo/[node:nid]" in an image field configuration, the form does not validate. The error text is: "The File directory is using the following invalid tokens: [node:nid]".
As per File (Field) Paths, core does not support node tokens for this. This is a feature request to get this into core. It will greatly help folks keep their "files" directory clean.
Also see ImageField Tokens.
Comments
Comment #1
Deciphered CreditAttribution: Deciphered commentedI'm happy to lend a hand with issue, but it's worth noting that the reason that Node (or Entity) tokens don't work by default is that they aren't necessarily known until after the Node (or Entity) has been saved, which is why File (Field) Paths does the processing after the Node (or Entity) has been saved.
Comment #2
Andrew_Mallis CreditAttribution: Andrew_Mallis commented+1
Comment #2.0
Andrew_Mallis CreditAttribution: Andrew_Mallis commentedAdded link to second contrib project.
Comment #3
catchMarking duplicate of #2592251: Uploading files should have more robust default tokens.