|
MaximumImageSize<< Picture Gallery | Cookbook-V1 | Wiki Smileys >> Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.
GoalPrevent images wider than a certain number of pixels from getting automatically inlined, ruining the usability of the site. SolutionAdd the following code into your local configuration file and change the value of $ImageMaxWidth to taste:
$ImageMaxWidth = 600;
function MyFmtUrlLink($pat,$ref,$txt) {
global $InterMapUrls, $ImgExtPattern, $UrlLinkFmt, $UrlImgFmt, $UrlLinkTextFmt, $ImageMaxWidth;
$link = $UrlLinkFmt; $rtxt=$ref;
$isimage=false;
if (!is_null($txt)) { $rtxt=$txt; $link=$UrlLinkTextFmt; }
elseif (preg_match("/$ImgExtPattern\$/",$ref))
{
$isimage=true;
}
if (preg_match('/^([^:]*):/',$ref,$match)) {
if (@$InterMapUrls[$match[1]])
$ref=preg_replace("/^$pat\$/",$InterMapUrls[$match[1]],$ref);
}
if ($isimage)
{
list($width, $height, $type, $attr) = getimagesize($ref);
if ($width < $ImageMaxWidth) $link=$UrlImgFmt;
}
$link = str_replace('$Url',$ref,$link);
return str_replace('$LinkText',$rtxt,$link);
}
$FmtUrlLink = 'MyFmtUrlLink';
See AlsoFor a more full-featured approach, have a look at PictureGallery. Comments & BugsThis code performs an additional access to the disk subsystem (through the No bugs are known at this time. AcknowledgementsI would like to thank Pm and the rest of the PmWiki team for producing such a cleanly designed and flexible implementation. Contributors
pmwiki-2.2.0-beta68 -- Last modified by {{Simon}}
|