Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
The core file module (Drupal\file\Plugin\Field\FieldFormatter\GenericFileFormatter
) relies on template_preprocess_file_link()
to print file type attributes and additionally provides a span
wrapper for a download link.
This is useful with theming when one wants to add a download icon for instance.
Proposed resolution
Follow the core and provide file type attributes as well as span
wrapper around the media download link.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#5 | 3076527-print-file-type-attributes-5-2-interdiff.txt | 2.1 KB | mbovan |
#5 | 3076527-print-file-type-attributes-5.patch | 1.9 KB | mbovan |
| |||
#2 | 3076527-print-file-type-attributes-2.patch | 1.99 KB | mbovan |
Comments
Comment #2
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedI am uploading the least disruptive way I could find to accomplish the task without introducing a new template. However, a new template might be a better solution?
The code borrows some logic from
template_preprocess_file_link()
.Comment #3
BerdirI think that @todo is bogus, formatters aren't typed data, they are regular plugins and can use DI.
That said, the code is just moved around and kinda unrelated to clean that up here.
Lets use $item->target_id here.
hm, kinda ugly, wondering if we want to add a template for this, similar to file_link.
Alternatively, we could maybe add the clases on the link, that might be enough for theming? I'll try to get some input on that.
Comment #4
Berdir3. Discussed a bit, lets just add those classes to the link.
Comment #5
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedAddressed #3.2 and #3.3.
Comment #7
BerdirCommitted and pushed, thanks.