In my Drupal usage and experience I have come to use many modules. But often I find myself learning new features about a module I’ve been previously using. When this happens I try to evaluate how this makes the module more flexible, or limiting if I encountered a bug I didn’t expect. A module I use often is Filefield Sources — but until recently I did not know it could easily move files around your file-system (within reason).
I have a website that allows students to submit images via a Webform for staff to collect and use elsewhere in digital and print media. Staff should be able to get the uploaded files from an FTP directory setup for the client. Recently I was told:
- The uploaded images did not have the correct filenames format, nor were they found within the expected FTP directory (oops).
- In a Drupal meeting today a co-worker said sometimes he wishes he could move a Fields upload directory someplace other than sites/default/files (eg, out of a big catch all file uploads directory).
FileField Sources module can fix both of these issues! WITH 0 CODE CHANGES! Wooo!
Filefield Sources basically extends the basic File type with additional file location options (for starters). So per file you can provide a destination location directory for the file field, if you have Tokens enabled on your site you can use any of the Nodes tokens to create the filename. This solves issue (1) above.
Filefield Sources also provides a mechanism (which should be tried outside of your production site first!) to retroactively change existing saved file fields to new destination locations based on the destination rule. It uses the Batch API on the backend to support hundreds (or thousands) of files! This solves issue (2) above.
An example of this field configuration is:
Note: One option I’m aware of and is a best-practice, but have yet to actually use on my sites is the Transliteration module which Filefield Sources may use if installed. This option would change bad filenames like “Mary ~~ 11.jpg” to say “mary__11.jpg” for example. Also this module has Drush integration so moving files and setting file path rules can be done via the command line even … sweet!
I hope you find these interesting features of the Filefield Sources module really helpful — I know I did!
Looking for quality web hosting? Look no further than Arvixe Web Hosting!