function theme_filefield_file in FileField 6.3
Theme function for the 'generic' single file formatter.
3 theme calls to theme_filefield_file()
- FileFieldDisplayTestCase::testNodeDisplay in tests/
filefield.test - Test normal formatter display on node display.
- theme_filefield_item in ./
filefield_formatter.inc - Theme function for any file that is managed by FileField.
- theme_filefield_widget_preview in ./
filefield_widget.inc
File
- ./
filefield_formatter.inc, line 112 - FileField: Defines a CCK file field type.
Code
function theme_filefield_file($file) {
// Views may call this function with a NULL value, return an empty string.
if (empty($file['fid'])) {
return '';
}
$path = $file['filepath'];
// Check for remote filepath, if so return the raw path with protocol prefix
if (strpos($path, 'http://') === 0 || strpos($path, 'https://' === 0)) {
return l($file['filename'], $path);
}
else {
$url = file_create_url(field_file_urlencode_path($path));
}
$icon = theme('filefield_icon', $file);
// Set options as per anchor format described at
// http://microformats.org/wiki/file-format-examples
// TODO: Possibly move to until I move to the more complex format described
// at http://darrelopry.com/story/microformats-and-media-rfc-if-you-js-or-css
$options = array(
'attributes' => array(
'type' => $file['filemime'] . '; length=' . $file['filesize'],
),
);
// Use the description as the link text if available.
if (empty($file['data']['description'])) {
$link_text = $file['filename'];
}
else {
$link_text = $file['data']['description'];
$options['attributes']['title'] = $file['filename'];
}
return '<div class="filefield-file">' . $icon . l($link_text, $url, $options) . '</div>';
}