0

My media browser has a list of powerpoint and visio files:

Media Browser Library tab

How can I add a download link or preview it next to each file? The idea is to make it easier for user to choose which file they want before saving the content. I am using media module 7x-2.8.

1
  • Just to add, I saw the "Media Browser" view but the "fields" are showing "the selected style or row format does not utilize fields.". I'm not sure if the only way to customise it is to implement hook_media_browser_plugin_info() and hook_media_browser_plugin_view() – xelat Nov 23 '17 at 5:07
0

1 Create your view, add the fields you'd like displayed.

2 On the "Content: Video" field settings, choose the "preview" option under formatter - this displays the thumbnail.

3 Add the "Content: Path" field to your view

4 Uncheck the settings for label, check the box for "exclude from display"

5 Click on rewrite results and select "Use Absolute Link"

6 Next you'll need to reorder your fields so that "Content: Path" is above "Content: Video".

7 Edit your Content: Video settings.

8 Go to rewrite results and check "Output This Field as a Link".

9 Put [path] as the link path.

10 Save it.

You are done.

1
  • Unfortunately this does not work for me. The cck field can only accept those view with format="media browser". But if I select that format in the view, it cannot accept any custom fields. – xelat Nov 24 '17 at 3:10
0

I ended up using this to resolve the query.

  • Copied the entire function theme_media_thumbnail from sites/all/modules/media/includes/media.theme.inc into sites/all/themes/mytheme/template.php
  • Renamed the function to mytheme_media_thumbnail
  • Added these lines before this line return $output:

    if ($element['#file']->type=='document') { // add download link below the file $url = file_create_url($element['#file']->uri); $output .= '<br />'.l('Download', $url); }

These sites were useful during my research:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.