function template_preprocess_media_views_view_media_browser

cis7 media.views.inc template_preprocess_media_views_view_media_browser(&$vars)
cle7 media.views.inc template_preprocess_media_views_view_media_browser(&$vars)
elmsmedia7 media.views.inc template_preprocess_media_views_view_media_browser(&$vars)
icor7 media.views.inc template_preprocess_media_views_view_media_browser(&$vars)
meedjum_blog7 media.views.inc template_preprocess_media_views_view_media_browser(&$vars)
mooc7 media.views.inc template_preprocess_media_views_view_media_browser(&$vars)

Display the view as a media browser.

File

sites/all/modules/ulmus/media/media.views.inc, line 62
Provide Views data and handlers for media.module

Code

function template_preprocess_media_views_view_media_browser(&$vars) {
  module_load_include('inc', 'media', 'includes/media.browser');
  // Load file objects for each View result.
  $fids = array();
  foreach ($vars['rows'] as $index => $row) {
    // The Search API module returns the row in a slightly different format,
    // so convert it to the format that the normal file_managed table returns.
    if (!empty($row->entity->fid)) {
      $vars['rows'][$index]->fid = $row->entity->fid;
    }
    $fids[$index] = $row->fid;
  }
  $files = file_load_multiple($fids);

  // Render the preview for each file.
  foreach ($vars['rows'] as $index => $row) {
    $file = $files[$row->fid];
    // Add url/preview to the file object.
    media_browser_build_media_item($file);
    $vars['rows'][$index] = $file;
    $vars['rows'][$index]->preview = $file->preview;
  }

  // Add the files to JS so that they are accessible inside the browser.
  drupal_add_js(array('media' => array('files' => array_values($files))), 'setting');

  // Add the browser parameters to the settings and that this display exists.
  drupal_add_js(array(
    'media' => array(
      'browser' => array(
        'params' => media_get_browser_params(),
        'views' => array(
          $vars['view']->name => array(
            $vars['view']->current_display,
          ),
        ),
      ),
    ),
  ), 'setting');

  // Add classes and wrappers from the style plugin.
  $handler = $vars['view']->style_plugin;

  $class = explode(' ', $handler->options['class']);
  $class = array_map('drupal_clean_css_identifier', $class);

  $wrapper_class = explode(' ', $handler->options['wrapper_class']);
  $wrapper_class = array_map('drupal_clean_css_identifier', $wrapper_class);

  $vars['class'] = implode(' ', $class);
  $vars['wrapper_class'] = implode(' ', $wrapper_class);
  $vars['wrapper_prefix'] = '<div class="' . implode(' ', $wrapper_class) . '">';
  $vars['wrapper_suffix'] = '</div>';
  $vars['list_type_prefix'] = '<' . $handler->options['type'] . ' id="media-browser-library-list" class="' . implode(' ', $class) . '">';
  $vars['list_type_suffix'] = '</' . $handler->options['type'] . '>';

  // Run theming variables through a standard Views preprocess function.
  template_preprocess_views_view_unformatted($vars);

  // Add media browser javascript and CSS.
  drupal_add_js(drupal_get_path('module', 'media') . '/js/plugins/media.views.js');
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.