Skip to main content
drupalreleases
Release: Cms 2.2.3 — Update released for Drupal core (2.2.3)! Release: Easy Breadcrumb 2.0.11 — Minor update available for module easy_breadcrumb (2.0.11). Release: Bootstrap 8.x-3.42 — Minor update available for theme bootstrap (8.x-3.42). Release: Editoria11y Accessibility Checker 3.0.10 — Minor update available for module editoria11y (3.0.10). Release: Editoria11y Accessibility Checker 2.2.24 — Minor update available for module editoria11y (2.2.24). Release: Leaflet 10.4.13 — Minor update available for module leaflet (10.4.13). Release: Flag 5.1.1 — Minor update available for module flag (5.1.1). Release: Layout Paragraphs 3.0.0-beta5 — New beta version released for module layout_paragraphs (3.0.0-beta5). Module Revived: Bootstrap 8.x-3.41 — Theme bootstrap updated after 6 months of inactivity (8.x-3.41). Security Coverage: Component Library — Module component_library now has official Drupal security advisory coverage.

File Download Link

5,200 sites Security covered Drupal 9–11
View on drupal.org

This module provides a flexible field formatter for displaying file and image fields as download links. It allows customization of link text, target attributes, and adds CSS classes for styling. An optional submodule also enables rendering media reference fields with their source files as download links.

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:

  1. 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.)
  2. Go to the "Manage Display" page for the node type.
  3. Select "File Download Link" as the formatter for your File or Image field.
  4. 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

  1. Install the file_download_link_media submodule.
  2. 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.)
  3. Go to the "Manage Display" page for the node type.
  4. Select "File Download Link" as the formatter for the Media reference field.
  5. 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.

Depends on

Dependencies of the latest stable release

  • file Drupal core

Required by

1 tracked project depends on this one

Activity

Tracked releases
2
Tracked since
Jul 2024
Latest release
3 months ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Releases

Version Type Core Release date
2.0.5 Stable 9–11 Jun 30, 2026
2.0.4 Stable 9–11 Jul 9, 2024