Drupal is a registered trademark of Dries Buytaert
Release: Drupal 10.3.6 Update released for Drupal core (10.3.6)! Release: Drupal 11.0.5 Update released for Drupal core (11.0.5)! Release: Drupal 10.2.9 Update released for Drupal core (10.2.9)! Release: Drupal 10.2.10 Update released for Drupal core (10.2.10)! Release: Drupal 10.3.7 Update released for Drupal core (10.3.7)! Release: Drupal 11.0.6 Update released for Drupal core (11.0.6)! Release: Drupal 10.3.8 Update released for Drupal core (10.3.8)! Release: Drupal 11.0.7 Update released for Drupal core (11.0.7)! Module Revived: Translation Management Tool 8.x-1.19 Module tmgmt updated after 7 months of inactivity (8.x-1.19). Usage Milestone: Account field split Module account_field_split crossed 10,000 active installs.

Media entity download solves a content management issue when dealing with files and media. Media entity download will prevent links from breaking when updating or uploading new files.

  • Content editors create media with a file
  • They want users to be able to download pdfs as links from content or blocks or paragraph items with WYSIWYGs, etc
  • They use the file path on the system, because thats what they're used to doing (/sites/default/files/foo/bar/document.pdf)
  • Later, they upload an updated file or a new file altogether
  • The file path / url changes
  • Now all existing links they created are broken in menus, WYSIWYGs, etc.
  • Someone now has to go back through and update dozens or potentially hundreds of broken links

By linking to the media/{media_id}/download route, none of the above really matters. Linking content to media/{media_id}/download will always fetch and return the right file without worrying that its the incorrect one, or outdated, or a unique url (document_0.pdf).

A field formatter is included ("Download Link") for Views based usage, or for when the media item itself is viewed (i.e. /media/{id}).

LinkIt is supported.

Creating a url in code is easy, you just need a media entity id. You can also optionally specify a delta value if the file field contains multiple values:

$url = Url::fromRoute(
  'media_entity_download.download',
  [
    'media' => $media_id,
  ],
  [
    'query' => [
      'delta' => $delta,
    ],
  ]
);

Versions

  1. 8.x-2.x - Compatible with Drupal 8.4.x to 10.3, requires Media module from Core
  2. 8.x-1.x - Compatible with Drupal 8.3.x and below, requires Media Entity module from Contrib

Contrib Support (8.x-1.x)

  • Media Entity 8.x-1.x
  • Media Entity Document 8.x-1.x
  • LinkIt 8.x-5.x

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Nov 2024
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Core Release date
8.x-2.4 Stable Nov 13, 2024