You are here

function theme_pdfpreview_formatter in PDFPreview 7

Same name and namespace in other branches
  1. 6 pdfpreview.module \theme_pdfpreview_formatter()
  2. 7.2 pdfpreview.module \theme_pdfpreview_formatter()

Theming functions for our formatters

@todo Clearify the image cache thing... @todo Let user choose what preview image to show on non-PDF files

1 string reference to 'theme_pdfpreview_formatter'
pdfpreview_theme in ./pdfpreview.module
Implements hook_theme().

File

./pdfpreview.module, line 259
This file contains hooks for the pdfpreview module

Code

function theme_pdfpreview_formatter($element) {
  $img_tag = '';
  $item = $element['item'];

  // TODO: Not sure what this part is doing...
  // if (list($namespace, $presetname) = explode('][', $element['#formatter'], 2)) {
  //   if ($preset = imagecache_preset_by_name($namespace)) {
  //     $output = theme('imagecache', $namespace, $output_filename, $item['data']['alt'], $item['data']['title']);
  //   }
  // }

  //debug($item);
  $file_url = file_create_url($item['uri']);
  $img_url = file_create_url($item['preview']);
  $title = $alt = $item['description'];
  $img_tag = sprintf('<img src="%s" title="%s" alt="%s" />', $img_url, $title, $alt);
  $wrapper_tag = variable_get('pdfpreview_tag', 'span');
  $description = variable_get("pdfpreview_description", 1) ? '<' . $wrapper_tag . ' class="pdfpreview-description">' . $title . '</' . $wrapper_tag . '>' : '';
  return sprintf('<div class="pdfpreview" id="pdfpreview-%s">' . ' <%s class="pdfpreview-image-wrapper"><a href="%s" title="%s">%s</a></%s>' . ' %s' . '</div>', $item['fid'], $wrapper_tag, $file_url, $title, $img_tag, $wrapper_tag, $description);
}