|
Cookbook /
AttachIcons2Summary: Add icon images to Attach file links according to file extension
Version:
Prerequisites:
Status:
Maintainer: Pierre Racine
Questions answered by this recipeHow can I automatically display an icon image specific to a file extension beside an attach link? DescriptionThe following markup adds an icon for .pdf and .doc files (but not others). Add the markup definition to config.php or another local customisation file. Extend and adjust the definition for other file extensions according to your needs. The link will open in a new window. Put the following code in your config.php. You also need to create icon images This recipe is different from AttachIcons in that it works for Markup('[[ext|','<[[|',"/(?>\\[\\[([^|\\]]*.([Pp][Dd][Ff]|[Dd][Oo][Cc]))\\s*\\|\\s*)(.*?)\\s*\\]\\]($SuffixPattern)/e",
"MakeLinkWithIcon(\$pagename, PSS('$1'), PSS('$2'), PSS('$3'),'$4')");
Markup('[[ext','<[[', "/(?>\\[\\[\\s*(.*?.([Pp][Dd][Ff]|[Dd][Oo][Cc]))\\s*\\]\\])($SuffixPattern)/e",
"MakeLinkWithIcon(\$pagename, PSS('$1'), PSS('$2'), NULL, '$3')");
function MakeLinkWithIcon($pagename, $target, $ext, $text, $suffix)
{
global $UrlLinkFmt;
$fmt = $UrlLinkFmt." <img src=/pub/icons/".$ext.".gif>";
if (strtolower($ext) != "zip")
$fmt = "%newwin%".$fmt;
if (is_null($text))
return Keep(MakeLink($pagename, PSS($target), NULL, $suffix, $fmt), 'L');
else
return Keep(MakeLink($pagename, PSS($target), PSS($text), $suffix, $fmt), 'L');
}
Get your doctype icons from here: www.stylegala.com/features/bulletmadness/ - link doesn't work Rename them to be named like this: Notes
Release Notes
CommentsSee AlsoContributors |