:) capability, which will produce a thumbnail link to a full-sized view of an uploaded image that, in turn, links back to the page. Version: 20060315 */ ## Allow override of default thumbnail height in local configuration. SDV($ThumbLinkHeight, '75'); ## (:thumb:) directive Markup('thumb', 'directives', '/\\(:thumb(\\s+.*?)?:\\)/ei', "FmtImageLink('', '', array('o' => PSS('$1 ')))"); ## FmtImageLink gets the options from (:imagelink:) and generates a ## self-referring link with ?action=imagelink&i= . function FmtImageLink($foo, $bar, $opt) { global $ImgExtPattern, $ThumbLinkHeight; $opt = ParseArgs($opt['o']); ## Accept only one "plain" argument. It must have an image's extension. if ($opt['']['1']) { return; } else { $img = $opt['']['0']; } if (! preg_match("/($ImgExtPattern)$/", $img)) { return; } ## Optionally accept width= and/or height= attributes. if ($opt['width'] && $opt['height']) $spacer=' '; if (!($opt['width']) && !($opt['height'])) $opt['height']=$ThumbLinkHeight; if ($opt['width']) $width='width='.$opt['width']; if ($opt['height']) $height = 'height='.$opt['height']; $out = '%'.@$width.@$spacer.@$height.'%[[{$FullName}?action=imagelink&i=' .$img.'|Attach:'.$img.']]%%'; // TODO: I don't know what this does! :-) ??? $out = preg_replace('/^(<[^>]+>)(.*)/esm', "PSS('$1').Keep(PSS('$2'))", $out); return PRR($out); } ## Code after this is only for an image-display page. if ($action != 'imagelink') { return; } ## Create a {$RequestedImage} page variable for ?i=. if (preg_match("/($ImgExtPattern)$/", @$_REQUEST['i'])) { $FmtPV['$RequestedImage'] = "'".htmlspecialchars(@$_REQUEST['i'], ENT_QUOTES)."'"; } else { return; } SDV($HandleActions['imagelink'], 'HandleImageLink'); SDV($HandleAuth['imagelink'], 'read'); ## HandleImageLink performs ?action=imagelink, which uses $SiteGroup.ImageLink ## as a template to display the requested image. function HandleImageLink($pagename, $level = 'read') { global $PageImageLink, $FmtV, $HandleImageLinkFmt, $PageStartFmt, $PageEndFmt, $HTMLStylesFmt; $HTMLStylesFmt['wikicmds'] = "\n $[ #wikicmds { display:none; } ]"; SDV($HandleImageLinkFmt,array(&$PageStartFmt, '$PageText', &$PageEndFmt)); SDV($PageImageLink, '$[$SiteGroup/ImageLink]'); PCache($pagename, RetrieveAuthPage($pagename, 'read')); $form = ReadPage(FmtPageName($PageImageLink, $pagename), READPAGE_CURRENT); $text = @$form['text']; if (!$text) $text = '(:noleft:)(:noright:)(:notitle:)(:noheader:)(:nofooter:)' .'%center margin:0.5em%[[{$FullName}|Attach:{$FullName}/{$RequestedImage}]]%%'; $FmtV['$PageText'] = MarkupToHTML($pagename,$text); PrintFmt($pagename, $HandleImageLinkFmt); }