Skip to content

Instantly share code, notes, and snippets.

@opi
Created May 23, 2013 12:18
Show Gist options
  • Select an option

  • Save opi/5635657 to your computer and use it in GitHub Desktop.

Select an option

Save opi/5635657 to your computer and use it in GitHub Desktop.
Quick'n'dirty solve for media pdf bug
<?php
/**
* Implements hook_preprocess_media_views_view_media_browser()
*/
function mymodule_preprocess_media_views_view_media_browser(&$vars) {
foreach ($vars['rows'] as $delta => $row) {
if ($row->filemime == 'application/pdf') {
// See http://drupal.org/node/1743040
$vars['rows'][$delta]->preview = l(
'<div class="media-item media-item-pdf">'.$row->filename.'</div>',
'media/browser',
array(
'html' => TRUE,
'attributes' => array(
'data-fid' => $row->fid,
),
'query' => array(
'render' => 'media-popup',
'fid' => $row->fid
),
)
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment