function itweak_upload_itweak_upload_preview in iTweak Upload 6.2
Same name and namespace in other branches
- 7.3 itweak_upload.module \itweak_upload_itweak_upload_preview()
Implementation of hook_itweak_upload_preview().
Parameters
$file: File object, same type as nodeapi 'view' "if ($node->nid) foreach ($node->files as $fid => $file) ..."
$derivative: Name of thumbnail preset, or one of '_none' (no preview), '_original'.
$show_title: If TRUE, insert thumbnail link title (used in open thumbnail method).
$show_caption: If TRUE, shows thumbnail caption. UNUSED hack: If 2 or 3 - appends text after link (for list-formatted view).
$options: Optional. Array of options for the thumbnail link. Can add special handler.
Return value
FormsAPI item element with file preview (if available)
File
- ./
itweak_upload.module, line 177 - iTweakUpload - Tweak attachments display and file upload forms.
Code
function itweak_upload_itweak_upload_preview($file, $derivative, $show_title = FALSE, $show_caption = FALSE, $options = NULL) {
// Only check for images
if (_itweak_upload_isimage($file)) {
$text = empty($file->description) ? $file->filename : $file->description;
$href = _itweak_upload_file_create_url($file);
if ($derivative == '_none') {
return;
}
elseif ($derivative == '_original') {
$thumbnail = theme('image', file_create_path($file->filepath), $text, $text);
}
else {
$thumbnail = theme('imagecache', $derivative, file_create_path($file->filepath), $text, $text);
}
$text = check_plain($text);
// Hack: if ($show_caption > 1) { $thumbnail = $thumbnail . $text; $show_caption -= 2; }
$title_text = $show_title ? $text : NULL;
$caption_text = $show_caption ? $text : NULL;
return array(
'#type' => 'item',
'#value' => theme('itweak_upload_thumbnail', $thumbnail, $href, $title_text, $caption_text, $options),
);
}
}