cross
New Foswiki release 2.1.6 is available with important security fixes.
Sourceforge foswiki email lists being discontinued. Subscribe to the new Foswiki announce and discuss lists at MailingLists
You are here: Foswiki>Tasks Web>Item13212 (05 Jul 2015, GeorgeClark)Edit Attach

Item13212: Process to add a filetype icon to the attachment table is not documented.

pencil
Priority: Normal
Current State: Closed
Released In: 2.0.0
Target Release: major
Applies To: Engine
Component: Documentation, FoswikiAttach, ICON
Branches: master
Reported By: LucasNava
Waiting For:
Last Change By: GeorgeClark
-- 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
 

ItemTemplate edit

Summary Process to add a filetype icon to the attachment table is not documented.
ReportedBy LucasNava
Codebase 1.1.9
SVN Range
AppliesTo Engine
Component Documentation, FoswikiAttach, ICON
Priority Normal
CurrentState Closed
WaitingFor
Checkins distro:345c6f0ab389
TargetRelease major
ReleasedIn 2.0.0
CheckinsOnBranches master
trunkCheckins
masterCheckins distro:345c6f0ab389
ItemBranchCheckins
Release01x01Checkins
Topic revision: r6 - 05 Jul 2015, GeorgeClark - This page was cached on 21 Mar 2018 - 20:18.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License