File size on View
portulaca - July 5, 2009 - 19:03
| Project: | FileField |
| Version: | 6.x-3.1 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
I can see the sile size when in Edit mode of a node where Filefield is present, is there a way to show it in View mode too?

#1
Yes, you can override the theme_filefield_item().
- Find theme_filefield_item() in filefield.formatter.inc.
- Copy the entire function to your theme's template.php file, rename it to [your_theme_name]_filefield_item().
- Add the file size to the output.
<?phpfunction [yourtheme]_filefield_item($file, $field) {
if (filefield_view_access($field['field_name']) && filefield_file_listed($file, $field)) {
return theme('filefield_file', $file) . format_size($file['filesize']);
}
return '';
}
?>
#2
wow speedy reply :)
I tested this on my local drupal and it works! Thank you!
#3
Nice. FileField provides several different levels at which you can intercept the output, this one seemed most appropriate for what you're trying to do. You can do the same thing with any other theme_* functions if this one doesn't do exactly what you want.
#4
Automatically closed -- issue fixed for 2 weeks with no activity.