Can Anybody please tell me how to get the media browser to show additional information?
I want to have some of the field data of the files to be displayed...

First attempt: just add the fields to the 'preview' view mode - - does not change anything in the media browser.

Second attempt: change the media browser view/display: if I want to add fields here, I have to change the format from 'media browser' to 'fields', which gives me the desired output, but looses all the functionality (e.g. selecting files)

Third attempt: try to reconstruct the markup necessary for the functionality in my own template (views-view-list--media-browser-2.tpl.php) but I don't seem to be able to get all the variables - can I just copy the template_preprocess_media_views_view_media_browser() function into my theme template.php?
And if so, would mytheme_preprocess_views_view_list_media_browser_2() be the right name?
(that's what I tried, and the preprocessing function is not called...)

I'd be grateful for any help - I hope you realise that the default thumbnail-and-filename preview in the media browser (library) is not the perfect solution for every purpose.

eR

Comments

arthurf’s picture

You might want to take a look at the patch that got submitted in #1743040: "You have not selected anything!" error message, when a selection has clearly been made which changes how individual items in the browser get wrapped. If you can duplicate this markup around each item that you return in your view it will likely work for you. You'll need to make sure that the JS is added as well. There is some proto code on http://drupal.org/node/1806812 that might be useful to look at- not sure.

enochRoot’s picture

Thanks for your help,

I think I could get the markup right, if I knew the right combination of .tpl file and preprocessing function to use.
Can you tell me how to name the preprocessing function (that's also where the js is added, right?) to have all the variables available in my theme?

greetings,
eR

arthurf’s picture

If you're just modifying the existing view, you need to change line 82 $vars['rows'][$index]->preview = $file->preview; to use a theme function that delivers the markup you want. media-views-view-media-browser.tpl.php is the wrapper for that content.

enochRoot’s picture

Thanks again,

I suppose you mean line 82 of media.views.inc, which actually is line 80 in my version of the file.
But I already had figured out this template and preprocessing function would be the place to change stuff. I'd rather have my own override though, so my question remains:
If I have my own display for the media browser view, and my own template (a clone of media-views-view-media-browser.tpl.php) in my theme folder - - Is it possible to have my own template_preprocess_media_views_view_media_browser() function within my theme, and if so, how should it be named?

thx,
eR

funana’s picture

Issue summary: View changes

I know it's an old issue, but I search for a while now and couldn't find any solution for this.

How to theme the media browser and add additional informations to the file preview (i.a. ALT or custom field contents)?

Any help appreciated!

kenianbei’s picture

Just googled to find the easiest way to alter the media browser and found this issue. In media.browser.inc there is this line:

  // Allow modules to change the tab names or whatever else they want to change
  // before we render.  Perhaps this should be an alter on the theming function
  // that we should write to be making the tabs.
  drupal_alter('media_browser_plugins', $plugin_output);

So you can just add these lines to a custom module:

/**
 * Implements media_browser_plugins_alter().
 */
function MODULE_media_browser_plugins_alter(&$plugin_output) {
  dpm($plugin_output);
}

You should also be able to override media-dialog-page.tpl.php in some cases as well (in my case I need to add classes to the buttons for theming purposes, so I used the alter above).

Chris Matthews’s picture

Status: Active » Closed (outdated)

Closing this issue as outdated. However, if you think this issue is still important, please let us know and we will gladly re-open it for review.
sincerely,
- the Drupal Media Team