Sorry for continuously ping the queue this morning. I think this is the third time.
Anyway, I've written up a module to tag imagefields files with taxonomic terms, and I was wondering if there is a need or a similar module out there.
This uses the hook_field_settings() to associate a FileField with any Vocabulary, and then appends the selected vocab selects to the data array using a #preprcess function on both the imagefield_widget / filefield_widget elements. The four file hooks are used to load, save and delete the data.
I'm heading off on a one year road trip, so I really do not want to publish this one week before taking off, but I thought that I would share the code.
Missing functionality is to hook into the taxonomy delete hooks to remove terms that are deleted from filefield_term table, updating the system weight by one to prevent conflicts with FileField, to integrate with views and to build in the best practice for securely loading images without having to fall back to file_download() permission checks (if possible).
The motivation behind this was to create a way to be able to tag individual images with terms so that a selected subset could be shown in random blocks, without the need to unserialize each imagefield data array to check if this was selected (using ImageField Extended). I could potentially have 1000's images taken on the trip, and the performance of that would have been too high.
Plus this approach could potentially be used to port ImageField Extended to Drupal 7.
| Comment | File | Size | Author |
|---|---|---|---|
| filefield_terms.zip | 2.71 KB | alan d. |
Comments
Comment #1
quicksketchThanks for sharing your code. I'd note that this is not necessary (directly) in Drupal 7 because File are now first-class objects and (with a little work) can have the FieldAPI applied to them. Since Taxonomy terms are now fields, you can add any number of fields (or even comments) to individual $file objects, essentially putting them directly on the same level as nodes. However there is no UI for this in core, so some work definitely still needs to be put in place to support that (though that may be already included in Media module, I haven't actually checked).
Comment #2
alan d. commentedSounds too easy! Thanks.
Comment #4
juliavdw commentedJust wanted to let you know that your module solved an issue I had with a site very nicely. Thank you for sharing! :)
Comment #5
markporter commentedThis would be exactly what I need right now if it had the views integration. Is this still being worked on at all? I'm still using Drupal 6...