Posted by jimmb on October 10, 2007 at 9:20pm
Jump to:
| Project: | FileField |
| Version: | 5.x-2.2 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | jimmb |
| Status: | closed (fixed) |
Issue Summary
Hello, we have a site in development at http://cogent-tech.com
I've set up a CCK field for products so they can upload files (like user manuals and movies) and have them display in a block. I was told that via the ICO folder in the Filefield module folder an icon would automatically attach to a corresponding file type.
I've uploaded 2 .pdfs on a test page here: http://cogent-tech.com/node/77
But as you can see the icons aren't showing up. We can't figure out why, so I'm submitting this as a Support Request because I can't be sure yet whether it's a bug or something we're doing wrong on this end.
Thanks for your help,
Jim
Comments
#1
Hm, no, the images in ico/ are only added to the form widget on the node edit page, but not to the resulting node view output. I didn't think about this before, no idea if it would be a good idea or not. It would, however, be quite trivial to add such a picture by means of filefield theming - here's an untested, minimally modified version of theme_filefield() that you would insert into your template.php:
function phptemplate_filefield($file) {
if (is_file($file['filepath']) && $file['list']) {
$path = ($file['fid'] == 'upload')
? file_create_filename($file['filename'], file_create_path($field['widget']['file_path']))
: $file['filepath'];
$icon = theme('filefield_icon', $file);
$url = file_create_url($path);
$name = $file['filename'];
$desc = $file['description'];
return $icon .'<a href="'. check_url($url) .'">'. check_plain($desc) .'</a>';
}
return '';
}
No guarantees, but I think this should sufficiently work (at least if you've got icons for all possible file types, otherwise there can be a missing image for some files).
#2