The File (Field) Paths module extends the default functionality of Drupal's core File module, Image module and many other File upload modules, by adding the ability to use entity based tokens in destination paths and file names.
In simple terms, File (Field) Paths allows you to automatically sort and rename your uploaded files using token based replacement patterns to maintain a nice clean filesystem.
For a full description of the module, visit the project page.
Submit bug reports and feature suggestions, or track changes in the issue queue.
- Requirements
- Installation
- Configuration
- Features
- FAQ
- Maintainers
This module requires the following modules:
Install as you would normally install a contributed Drupal module. For further information, see Installing Drupal Modules.
Once installed, File (Field) Paths needs to be configured for each file field you wish to use. Settings can be found on the settings form of any supported file based field:
Administration > Structure > Content types > Article > Manage fields > Image
/admin/structure/types/manage/article/fields/node.article.field_image
File (Field) Paths uploads each file to a temporary location first and moves it
to its final path once the entity is saved and the token values are known. If
that location is under public://, a file bound for the private file system can
be read by anyone who knows its URL until the entity is saved.
A new install uses temporary://filefield_paths. Keep it. Files there have no
public URL, and image previews still work: image styles are built for staged
files on demand.
If temporary:// does not suit your server, use the
private file system
instead. One such case is several web servers without a shared temporary
directory:
- Set a private file path in
settings.php, as described under Private file system settings. With several web servers, that path must be on storage they all share. - On "File (Field) Paths settings"
(
/admin/config/media/file-system/filefield-paths), set "Temporary file location" toprivate://filefield_paths.
The status report warns when the temporary file location points at public://
while a safer scheme is available.
- Configurable file paths now use entity tokens in addition to user tokens.
- Configurable file names.
- A generated name always ends in an extension the field allows. When the pattern does not give one, the file's own extension is added.
- Generated names are sanitised the way core sanitises an uploaded file name, with the same file system settings.
- Support for file based fields, including but not limited to:
- Drupal core File module.
- Drupal core Image module.
- Video module.
- File path and filename cleanup options:
- Remove slashes from tokens.
- Filter out words and punctuation by taking advantage of the Pathauto module.
- Convert unicode characters into US-ASCII with the Transliteration module.
- Retroactive updates - rename and/or move previously uploaded files.
- Active updating - actively rename and/or move previously uploaded files.
- Create redirect - automatically create a redirect when moving uploaded files, using the Redirect module.
Q: Aren't tokens already supported in the File module?
A: A limited selection of tokens are supported in the File module.
Entity based tokens allow you to use the Entity ID, Title, creation date and much more in your directory/filenames where you would otherwise be unable.
Q: Why aren't my files in the correct folder?
A: When you are creating or updating an entity the full values for the tokens may not yet be known by Drupal, so the File (Field) Paths module will upload your files to a temporary location and then once you save the entity and Drupal is provided with the tokens values the file will be moved to the appropriate location.
Q: Why is there a warning on the 'Retroactive updates' feature?
A: Retroactive updates will go through every single entity of the particular bundle and move and/or rename the files.
While there have been no reports of errors caused by the feature, it is quite possible that the moving/renaming of these files could break links. It is strongly advised that you only use this functionality on your developmental servers so that you can make sure not to introduce any linking issues.
- Oleh Vehera - voleger
- Stuart Clark - Deciphered
- David Pagini - dpagini