create new tag
, view all tags

Feature Proposal: Let %ICON{}% calculate the size of the image


ICON currently writes image properties height and width of 16 pixels. In a lot of circumstances this is too big for an icon, but to put a smaller sized icon in a topic one has to revert to

<img src="%ICONPATH{some-image}%" border="0" alt="" width="14" height="13" />

Description and Documentation

When using %ICON{}%, TWiki code should calculate the actual image dimensions and write these as html image properties.


Impact and Available Solutions

Note: Patch is attached as http://twiki.org/p/pub/Codev/LetICONCalculateImageSize/twiki-foo-bar-patch.diff. The patch is against the TWikiAlphaRelease of 15 Feb 2004.


-- Contributors: ArthurClemens


If that's too difficult you could always extend the icon sytax to allow specifying it in the tag:

%ICON{"some-image" width="14" height="13"}%

-- SamHasler - 19 Oct 2005

This is a useful enhancement. It requires caching of the icon size for quick delivery of icons. See also related TWikiDocGraphicsInMainWeb that also depends on caching.

-- PeterThoeny - 11 Feb 2006

why have these parameters at all as they are not required for XHTML. you can then have any size icon and the code will not resize it. remove line 3607 in /lib/twiki.pm fixes this.

-- BrianTibbels - 28 Mar 2008

for the mundane...

3606:    return CGI::img( { src => $this->getIconUrl( 0, $iconFileName ),
3607:                width => 16, height=>16,
3608;                align => 'top', alt => $iconFileName, border => 0 });

/me agrees with BrianTibbels. Why have a restriction where one is not needed?

Reasons for:

  • a) serves the request above making ICON easier to enhance
  • b) makes twiki.pm one line less complex (and I think we should all be for that at this point, twiki.pm is up to 3978 lines of code. Who will contribute lucky line number 4,000? stay tuned...)

Reasons against:

  • Some currently commonly used icons which are quite happy being 16x16 may suddenly look rather out of place if this restriction is removed, we have to consider current implementation and usage (however broken). An examination of all builtin icons should confirm sizes are, in fact, what they should be before this line is considered for removal.
  • Server load: in a world of thousands of clients and one server, you want to delegate as much computations as possible to the client, not the server. On the other hand, a crontab script computing sizes in the background on changed icons (or better, recomputing them after attach/upload) could be the best solution. -- ColasNahaboo - 29 Mar 2008

-- TravisBarker - 29 Mar 2008

Reason to keep the size in the img tag: Speed. Browsers render pages faster, and/or do not recalculate the layout once the size of an image is understood. Since our icons are used quite frequently we should keep the size indicators in the img tag. Hence the need to cache the actual image sizes.

-- PeterThoeny - 29 Mar 2008

how about keeping a default size indicator in the img tag which can be overridden by a value passed to ICON? this would remove the speed issue and allow the ICON to have a bit more flexability/functionality.

-- TravisBarker - 29 Mar 2008

This is now implemented as part of TWikiDocGraphicsInMainWeb.

-- PeterThoeny - 2010-01-03

Edit | Attach | Watch | Print version | History: r9 < r8 < r7 < r6 < r5 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r9 - 2010-01-03 - PeterThoeny
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.