function theme_pdfpreview_formatter in PDFPreview 6
Same name and namespace in other branches
- 7.2 pdfpreview.module \theme_pdfpreview_formatter()
- 7 pdfpreview.module \theme_pdfpreview_formatter()
Theming functions for our formatters
1 string reference to 'theme_pdfpreview_formatter'
- pdfpreview_theme in ./
pdfpreview.module - Implements hook_theme().
File
- ./
pdfpreview.module, line 74 - This module creates a formatter for CCK filefields that shows a snapshot of the first page of pdf files as link to the file.
Code
function theme_pdfpreview_formatter($element) {
$output = '';
$item = $element['#item'];
if ($item['filemime'] != 'application/pdf' or $item['list'] != 1) {
return '';
}
$output_filename = _pdfpreview_create_preview($item);
$output = "<img src=\"/{$output_filename}\" title=\"{$item['data']['description']}\" alt=\"{$item['data']['description']}\" />";
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']);
}
}
$tag = variable_get('pdfpreview_tag', 'span');
$description = variable_get('pdfpreview_description', 1) ? "<{$tag} class=\"pdfpreview-description\">{$item['data']['description']}</{$tag}>" : '';
return "<div class=\"pdfpreview\" id=\"pdfpreview-{$item['fid']}\">\n <{$tag} class=\"image-wrapper\"><a href=\"/{$item['filepath']}\" title=\"{$item['data']['description']}\">\n {$output}</a></{$tag}>{$description}</div>";
}