Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I want to create a custom format for the filefield, to just display the associated icon for the file that has been uploaded. I cannot see a replacement token for the file icon.. can anyone help me out? I think I might need to do an Advanced formatter, but i'm not a coder, so need a little help if possible.
Thanks
Rich
Comments
Comment #1
rich_lang CreditAttribution: rich_lang commentedFor anyone else struggling with this, my quick fix was to assign a class to the [filefield-view] token in my custom formatter HTML code (basic mode), and then use CSS to target the class and hide the 'a' link.
Code was:
.filefield-view-icon-only .filefield-file a {display:none; visibility:hidden;}
It would still be nice to have a token for the icon though :-)
Comment #2
7h3kk1d CreditAttribution: 7h3kk1d commentedIs there any way to have the icon link to the file?
Comment #3
rich_lang CreditAttribution: rich_lang commentedYou could try wrapping a href tag around the icons replacement token, and set the link with another replacement token.
Comment #4
zJoriz CreditAttribution: zJoriz commentedDid you find anything out in the meantime? Did you find a valid replacement token for the file icon?
Same problem here: I've seen the icon get called successfully by strings of php code inserted in a custom php field for Views:
But I'm not skilled enough to use advanced view for custom formatter.
The thing I want is basically quite simple: I wish to use the link exactly like it appears in normal filefield output, but with a target="_blank" added to the link. After way too much hours of searching fiddling I got the view field working. After another half a day I've ended up with a custom formatter field for the full node, which does the same. However, the icon is missing.
Comment #5
funkytraffic CreditAttribution: funkytraffic commentedThis might help.
Comment #6
funkytraffic CreditAttribution: funkytraffic commentedFor 6 this might help, for 7 I donnot know.
Comment #7
Deciphered CreditAttribution: Deciphered commentedI am no longer supporting any Drupal 6 modules, as such I am marking this as closed.
However, I am open to taking on co-maintainers, if you wish to do so contact me via me D.o contact form.