Item13212: Process to add a filetype icon to the attachment table is not documented.
Priority: Normal
Current State: Closed
Released In: 2.0.0
Target Release: major
Applies To: Engine
Component: Documentation,
FoswikiAttach, ICON
Branches: master
--
LucasNava - 14 Jan 2015
The problem is with the way Icons are loaded with Attach.pm
Attach.pm (line 169-171):
elsif ( $attr eq 'ICON' ) {
return '
';
}
This can be fixed by making the following change:
elsif ( $attr eq 'ICON' ) {
$file =~ m/\.([^.]*)$/;
return '
';
}
--
LucasNava - 14 Jan 2015
That was my first Comment. Didn't format it quite right.
Attach.pm (line 169-171):
elsif ( $attr eq 'ICON' ) {
return '%ICON{"' . $file . '" default="else"}%';
}
Should be:
elsif ( $attr eq 'ICON' ) {
$file =~ m/\.([^.]*)$/;
return '%ICON{"' . $1 . '" default="else"}%';
}
--
LucasNava - 14 Jan 2015
Confirming that this fix works fine. Thanks
LucasNava.
This needs a little more digging to understand fully what's going on. Some filetypes get a correct icon in spite of the bug.
--
GeorgeClark - 14 Jan 2015
The fix works, but this isn't correct. I'm changing this to a documentation task, and we need to look at revisiting the ICON rendering in the 2.0 as there is a mixture of expansion paths, and it's applied inconsistently.
The filetype to icon mapping is done in Foswiki::Macros::ICON, not in Foswiki::Attach. The %ICON% macro is intended to be passed the full filename, and it falls back to an extension to icon mapping that is unfortunately not documented. Filetypes are mapped to icons via a hidden attachment:
System/DocumentGraphics/_filetypes.txt
.
See the
IRC Log for the discussion where we figured out what was going on.
--
GeorgeClark - 14 Jan 2015
There is
MimeIconPlugin that solves this issue, including the required mime type magic.
--
MichaelDaum - 14 Jan 2015