Media name as link to file I have a "Document" media bundle, and I have a custom view mode called "Embed".

In that view mode, I have removed everything except the media name property and my document file field.

For media name the only format available is plain text, with an option to "Link to Media". This provides a link like media/2, where you can click on a link to download the file.

For my document field, I get Generic file (the file name with a link to it), RSS enclosure, Table of files, and URL to file.

Does anyone have a simple way to generate a link like Generic file but show the media name instead of the file name? e.g. Handbook vs handbook__2017_fin_updated_some_other_rubish_26.pdf
This is not possible with just the formatter configuration, someone would need to create a "Link to file with entity label" formatter, which would also not be that complicated.

But you can do it quite easily directly in a media template, the name would be something like media--document--embed.html.twig and the content then looks like this:

&lt;div{{ attributes }}&gt;
  &lt;a class="document-link" title="{{ name }}" href="{{ file_url(elements['#media'].field_document.entity.uri.value) }}" target="_blank" rel="noopener"&gt;{{ name }}&lt;/a&gt;
&lt;/div&gt;


I also included a target and noopener rel here, but that's of course up to you.