If you want that an image becomes a link exactly like a usual description reference,
or in other words, that the text
becomes the image link in the top-right corner of this page,
apply the patch below to your Tavi 0.22 sources
(this one works fine on main image of the french site http://wikira.tuxfamily.org).
Return to TaviPatches.
Replace the portion of code
function parse_hyperlink_description($text)
{
global $UrlPtn;
return preg_replace("/\\[($UrlPtn) ([^]]+)]/e",
"url_token(q1('\\1'), q1('[\\4]'))", $text, -1);
}
with this one
function parse_image_ref($text)
{
if (preg_match('/(.jpe?g|.png|.gif|.bmp)$/i', $text))
{
return preg_replace('/(http:\/\/)([A-Za-z0-9\\/?=&~_.\-]*)(jpe?g|png|gif|bmp)/',
'<img src="\\1\\2\\3" border="0">', $text, -1);
}
else
{
return '[' . $text . ']';
}
}
function parse_hyperlink_description($text)
{
global $UrlPtn;
$str = preg_replace("/\\[($UrlPtn) ([^]]+)]/e",
"url_token(q1('\\1'), q1(parse_image_ref('\\4')))", $text, -1);
return $str;
}
Please, don't hesitate to critic my code below this line --LaurentJacques
If you would also like the benefit of TaviPatches/ExternalLinks simply substitute the above line:
return '[' . $text . ']';
with
return $text;
In the code q1(parse_image_ref('\\4')))", $text, -1), the 4 should be replaced by 2. (it probably refers to the statement's number in an [ ] (array))
This also goes for the original code (at least up to 0.24).
Thor.