Module Description
Media entity download seeks to solve a content management issue when dealing with files and media.


* 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 support is available in alpha3 release at a basic level. It will find the media download route, but there is no mechanism to suggest which file (for example, if the file field allows multiple values) to link to. It defaults to the first file.

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
* 8.x-2.x - Compatible with Drupal 8.4.x and above, requires Media module from Core
* 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

Project Usage
7720
Creation Date
Changed Date
Security Covered
Covered By Security Advisory
Version Available
Production
Module Summary
Media entity download module aims to solve the issue of broken links and outdated file paths by providing a reliable download route for media files, eliminating the need for manual updates.
Data Name
media_entity_download

OPENAI CHATBOT

OPENAI CHATBOT

16:30:36
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.