Module Description
The "File Download Link" Field Formatter This module provides a field formatter plugin for rendering File fields or Image fields as configurable download links. You can configure the link text, whether or not it opens the file in a new window, and whether or not to try to force download with the html5 download attribute. It also adds some helpful classes to the link in case you want to style different types of files in different ways.

In short, the formatter has these features:


* Configurable link text with token integration
* Configurable tooltip (i.e. title attribute) with token integration (not shown in screenshots)
* Configurable "target" attribute
* Configurable "download" attribute
* Automatic CSS class based on file type
* Configurable additional CSS classes on link with token integration

The submodule file_download_link_media allows you to directly render a Media reference field as a link the Media's source file or image. This may save you from having to configure a new view mode for Media in some cases.

Recommended Modules This module is a lot better if you have token installed, but no modules outside of core are required.

Conflict with file_entity module
If you are using the file_entity contributed module, you may run into problems since that module defines a Field Formatter with the ID file_download_link. This conflict is detailed in #3125733: Plugin ID clash with File Entity "file_download_link". That issue has a patch that you can use to make the file_download_link module compatible with file_entity. Since the file_entity module is deprecated, this patch will never actually be merged into any of our releases.

Configuration There is no global configuration for this module. To configure a File field or Image field to be displayed using the File Download Link formatter:


* Add File field or Image field to a node type. (Or you could add it to a Media type or Taxonomy vocabulary or Paragraph type. In this example we'll assume we're putting the field on a node type.)
* Go to the "Manage Display" page for the node type.
* Select "File Download Link" as the formatter for your File or Image field.
* Click the gear icon at the right of the form to configure the File Download Link formatter. See the introduction for descriptions of the various options.

Media Reference Fields

* Install the file_download_link_media submodule.
* Add Media reference field to a node type. Configure the field to allow Media types that use a file or an image as the source. (This will not work for oembed videos, for example.)
* Go to the "Manage Display" page for the node type.
* Select "File Download Link" as the formatter for the Media reference field.
* Click the gear icon at the right of the form to configure the File Download Link formatter. See the introduction for descriptions of the various options.

The images and files that are the sources for the referenced Media will be rendered directly as download links with no need to do any additional configuration of Media view modes.

Translation
When the link text is entirely composed of tokens, the link text (i.e. the token values) will be translated as expected. (If not, please put in an issue!) See #3119194: Language not handled correctly in token for a little more information.

However, if there is any static text in the link text, translation is difficult because there is no translation UI for entity view display. Please see #2546212: Entity view/form mode formatter/widget settings have no translation UI for details on the core issue as well as potentially helpful patches. Please see #3159900: How to translate link text? for details related to the File Download Link module specifically.

Similar Modules File Download provides a similar field formatter for File and Image fields (but not Media Reference fields), but there are several differences. That field formatter does not make the "target" or "download" attributes of the link configurable, nor does it allow the user to add classes to the link through configuration. In that formatter tokens can be used for the link title text, but the tokens do not work well if the field cardinality is greater than 1. Further, that formatter does not handle caching carefully when tokens are used. File Download Link (this module) allows much better use of tokens.

However, File Download offers functionality to count and display the number of times a given file has been downloaded. File Download Link (this module) does not have any counting functionality; it just provides highly configurable field formatters with good token integration.

Upgrading from 8.x-1.x to 2.0.x The 8.x-1.x branch will not support D10. You will need to upgrade to the 2.0.x branch. It's not a scary upgrade though! There aren't any update hooks or any special steps that you need to take.

Accessibility Accessibility guidelines often recommend listing the file type and file size as part of a download link. See for example a standard from the EPA. See this article from Accessabilly.com for some good ideas.

Project Usage
3784
Creation Date
Changed Date
Security Covered
Covered By Security Advisory
Version Available
Production
Module Summary
This module provides a field formatter plugin for rendering File fields or Image fields as configurable download links.
Data Name
file_download_link

OPENAI CHATBOT

OPENAI CHATBOT

14:37:09
Generic Chatbot
Hi, I'm a Drupal module expert powered by OpenAI, answering your questions about the Drupal module ecosystem. How can I be helpful today? Please note that we will log your question.