function asset_js_preview in Asset 5
Same name and namespace in other branches
- 6 asset.module \asset_js_preview()
Menu Callback from javascript to print an assets preview
1 call to asset_js_preview()
- asset_wizard_form in ./
asset_wizard.inc - Main form builder function for the asset wizard.
1 string reference to 'asset_js_preview'
- asset_menu in ./
asset.module - Implementation of hook_menu()
File
- ./
asset.module, line 648
Code
function asset_js_preview($aid, $show_details = true, $return = false) {
if (!isset($aid)) {
exit;
}
$asset = asset_load($aid);
$formatters = asset_get_formatters();
if (isset($formatters[$asset->type][$asset->extension][0])) {
$format = $formatters[$asset->type][$asset->extension][0];
}
elseif (isset($formatters[$asset->type]['*'][0])) {
$format = $formatters[$asset->type]['*'][0];
}
else {
$format = $formatters['*']['*'][0];
}
$output .= '<div>' . $asset->filename . '</div>';
$output .= asset_preview($asset->aid);
if ($show_details) {
$details[t('File Size')] = format_size($asset->filesize);
$details = array_merge($details, (array) module_invoke($format['module'], 'asset_formatter', 'details', $asset, $format));
foreach ($details as $label => $value) {
$output .= '<div><strong>' . check_plain($label) . '</strong>: ' . check_plain($value) . '</div>';
}
}
if ($return) {
return $output;
}
print $output;
exit;
}