function itweak_upload_itweak_upload_preview in iTweak Upload 7.3
Same name and namespace in other branches
- 6.2 itweak_upload.module \itweak_upload_itweak_upload_preview()
Implementation of hook_itweak_upload_preview().
Parameters
$file: File object. $file->path should be used first (if not empty) and $file->uri as a fallback for original file.
$thumbnail_style: 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 1150 - iTweakUpload - Tweak attachments display and file upload forms.
Code
function itweak_upload_itweak_upload_preview($file, $thumbnail_style, $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;
$url = empty($file->path) ? file_create_url($file->uri) : $file->path;
$title_text = $show_title ? $text : NULL;
$caption_text = $show_caption ? $text : NULL;
if ($thumbnail_style == '_none') {
return;
}
elseif ($thumbnail_style == '_original') {
$thumbnail = theme('image', array(
'path' => $file->uri,
'alt' => $text,
'title' => $title_text,
));
}
else {
$thumbnail = theme('image_style', array(
'style_name' => $thumbnail_style,
'path' => $file->uri,
'alt' => $text,
'title' => $title_text,
));
}
$text = check_plain($text);
// Hack: if ($show_caption > 1) { $thumbnail = $thumbnail . $text; $show_caption -= 2; }
return array(
'#type' => 'item',
'#value' => theme('itweak_upload_thumbnail', array(
'thumbnail' => $thumbnail,
'url' => $url,
'title_text' => $title_text,
'caption_text' => $caption_text,
'options' => $options,
)),
);
}
}