Closed (fixed)
Project:
FileField
Version:
6.x-3.x-dev
Component:
Documentation
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
2 Dec 2007 at 00:45 UTC
Updated:
17 Jun 2008 at 02:01 UTC
Jump to comment: Most recent file
Comments
Comment #1
mrtoner commentedBump. As far as I can tell, theme_filefield_icon() is not called when viewing a node, only when editing a node.
Comment #2
jpetso commentedThat's right, theme_filefield() is called when you view a node, and to get mimetype icons there you have to override theme_filefield() by theming. I think I already closed an issue asking for the exact same thing, you could search for it in the list of closed issues - if I'm correct there was even a code snippet in there. Let's leave this open, maybe we can enable icons by default when we ship an icon set with filefield.
Comment #3
mrtoner commentedIf I'm not mistaken, that was http://drupal.org/node/185902#comment-617408.
I've found a fairly decent source for open source icons at http://www.iconfinder.net/.
Don
Comment #4
encho commentedMan u rock! Thanks for the second link as well, being looking for it.
Comment #5
mrtoner commentedAn example of overriding theme_filefield(), using the info in that link, would be:
Comment #6
jpetso commentedThanks for the snippet, mrtoner. I would assume this support request can be regarded as "fixed", although I'm sure there'll be duplicate issues if I close it. Maybe something for the module documentation? I think I'll reassign this to the "Documentation" component... if someone wants to write up a few explanatory sentences and test the above snippet, here's your chance to contribute.
Comment #7
Rob T commentedThanks, mrtoner. This snippet came in handy.
Comment #8
dopry commentedAdd file type icons to theme_filefield.
Comment #9
jpetso commentedIt's getting time that I can justify my maintainer status again by doing a bit of work.
Find attached a patch that uses the shipped icons, complete with fallbacks (not *just* as flexible as the desktops with their "is also of mimetype xyz" subclassings, but still). The patch in its current form still hardcodes the "protocons" icon set without providing an opportunity to switch, and I also couldn't figure out how to let the icon div actually float left like the CSS file says it should. Using Firefox 3, my Firebug is currently out of order :(
If someone can fix the latter, this patch is not far from being ready. Works already, and using a temporary hack of replacing the div with a span it looked pretty nice already. @dopry: please review the function names in particular, I'm not quite sure with those.
Comment #10
jpetso commentedEr, oops. Never rename functions *after* you test the patch. Corrected patch now attached.
Comment #11
miles28 commentedAdding the filesize (KB):
function phptemplate_filefield ($file) {
if (user_access('view filefield uploads') && is_file($file['filepath']) && $file['list']) {
$path = ($file['fid'] == 'upload')
? file_create_filename($file['filename'], file_create_path($field['widget']['file_path']))
: $file['filepath'];
$url = file_create_url($path);
$name = $file['filename'];
$desc = $file['description'];
return theme('filefield_icon', $file) . ''. check_plain($desc) .'' . ' [' . (format_size($file['filesize'])) . ']';
}
return '';
}
Comment #12
jpetso commentedThis issue is about icons and should not include additional extensions like the filesize. Please create a proper patch and open a separate issue for that feature request. (Also, use the t() function for concatenating any user visible strings.)
Comment #13
dopry commentedjpetso, feel free to commit this as long as you've tested it and it works...
Comment #14
jpetso commentedCommitted with a lot more testing and a few bugfixes. Filefield now shows icons by default both on the edit form and on the node view, and more importantly, it uses the fd.o icon naming specification compliant names and fallback algorithms. No backwards compatibility has been provided for the previous extension-based selection of icons, so if you have customized your icon set then you need to adapt it to the new naming scheme.
Yeah, you are gonna like it. I do!
Comment #15
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.