Getting Media Downloads Happening in Views

Authored on
Wed, 05/29/2024 - 13:36
Tags
Body

Here is the way I set up a view that lets people download media in Drupal. Not sure it is the" correct" way but it seems to work for me and it's very flexible.

1. Go to /structure/views  
2. Click Add view  
3. Choose to show Media of type whatever you want downloads of.  
4. Choose "Create a block" and click save.  
5. In your block add a relationship and choose Image file.  
6. In Fields, add "URI". Exclude it from display and make sure "Display the file download URI" is checked.  
7. Click into Media: Name. Make sure link to media is unchecked. click rewrite results and then check" override the output of this field with custom text.  
8. Add this code...

<a href="//frozen-octopus.com/%7B%7B%20uri%20%7D%7D" download>{{ name }}</a>

9. Click Apply
10. Save the view.  
11. Place the Block somewhere and people willl be able to download media.

There is other ways to do it but I like the rewrite the field way. You have a lot of freedom to get your link looking and acting how you like it. 

 

 

Today's Albums

Title Artist Release Date Genre
Fractured Days Brief Candles Shoegaze
A Remarkable Machine Action Beat + G.W. Sok Post Punk
In Otherness Oneself Kaja Draksler Jazz