
Apache::Icon - Lookup icon images

use Apache::Icon ();
my $icon = Apache::Icon->new($subr);
my $img = $icon->find || $icon->default;
my $alt = $icon->alt;

This module rips out the icon guts of mod_autoindex and provides a Perl interface for looking up icon images. The motivation is to piggy-back the existing AddIcon and related directives for mapping file extensions and names to icons, while keeping things as small and fast as mod_autoindex does.

Create a new Apache::Icon object with the given Apache::SubRequest object. Example:
for my $entry (sort $dh->read) {
next if $entry eq '.';
my $subr = $r->lookup_file($entry);
my $icon = Apache::Icon->new($subr);
...
Lookup icon image associated with the subrequest.
my $img = $icon->find;
Lookup the default icon images.
my $img = $icon->default; #DefaultIcon (unknown.gif)
my $img = $icon->default("^^DIRECTORY^^"); #folder.gif
my $img = $icon->default("^^BLANKICON^^"); #blank.gif
Lookup the text alternative specified by the AddAlt directive.
my $alt = $icon->alt || $img;

Refer to the mod_autoindex documentation for directives listed here with no description.
This directive can be set to On or Off. The default is On if mod_autoindex is configured with the server, Off otherwise. When the directive is On, mod_icon directive handlers will return DECLINE_CMD after processing which allows mod_autoindex to also handle the various Icon and Alt directives.


Doug MacEachern
C code based on mod_autoindex by the Apache Group