12.10. Changing the Listing Icons
Problem
You want to use different icons in the directory listing.
Solution
Use AddIcon and its variants to specify which icons are to be used by different kinds of files:
AddIcon /icons/image.gif .gif .jpg .png
Discussion
There are a number of variants of the AddIcon directive that allow you to associate certain icons with various files, groups of files, or types of files.
The AddIcon directive sets an icon to be used for files that match a particular pattern. The first argument is the URI of the icon file to be used. The argument or arguments following this are file extensions, partial filenames, or complete filenames, with which this icon should be used.
You also can specify the argument ^^DIRECTORY^^ for directories, or ^^BLANKICON^^ to be used for blank lines, to
ensure correct spacing.
To specify an icon to be used for the parent directory link, use
an argument of "..":
AddIcon /icons/up_one.gif ".."
You also may use AddIconByEncoding to specify an icon to be
used for files with a particular encoding such as, x-gzip:
AddIconByEncoding /icons/gzip.gif x-gzip
Use AddIconByType for associating an icon with a particular MIME type:
AddIconByType /icons/text.gif text/* AddIconByType /icons/html.gif text/html
Finally, you can specify the default icon to be used if nothing else matches:
DefaultIcon /icons/unknown.png
With any of these directives, you also may specify an alternate text to be displayed for clients that have image loading turned off. The syntax for this ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access