Ludo wrote:I would also like to know how you did for floating images?
Ludo,
Well, it's quite simple really ;)
Open include/parser.php
Find:
//
// Turns an URL from the [img] tag into an <img> tag or a <a href...> tag
//
function handle_img_tag($url, $is_signature = false)
{
global $lang_common, $pun_config, $pun_user;
$img_tag = '<a href="'.$url.'"><'.$lang_common['Image link'].'></a>';
if ($is_signature && $pun_user['show_img_sig'] != '0')
$img_tag = '<img class="sigimage" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';
else if (!$is_signature && $pun_user['show_img'] != '0')
$img_tag = '<img class="postimg" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';
return $img_tag;
}
After add:
function handle_img_tag_left($url, $is_signature = false)
{
global $lang_common, $pun_config, $pun_user;
$img_tag = '<a href="'.$url.'"><'.$lang_common['Image link'].'></a>';
if ($is_signature && $pun_user['show_img_sig'] != '0')
$img_tag = '<img class="sigimage_left" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';
else if (!$is_signature && $pun_user['show_img'] != '0')
$img_tag = '<img class="postimg_left" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';
return $img_tag;
}
function handle_img_tag_right($url, $is_signature = false)
{
global $lang_common, $pun_config, $pun_user;
$img_tag = '<a href="'.$url.'"><'.$lang_common['Image link'].'></a>';
if ($is_signature && $pun_user['show_img_sig'] != '0')
$img_tag = '<img class="sigimage_right" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';
else if (!$is_signature && $pun_user['show_img'] != '0')
$img_tag = '<img class="postimg_right" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';
return $img_tag;
}
Find:
$text = preg_replace('#\[img\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e', 'handle_img_tag(\'$1$3\')', $text);
After add:
$text = preg_replace('#\[img=left\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e', 'handle_img_tag_left(\'$1$3\')', $text);
$text = preg_replace('#\[img=right\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e', 'handle_img_tag_right(\'$1$3\')', $text);
Find (yes, there's two of them):
$text = preg_replace('#\[img\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e', 'handle_img_tag(\'$1$3\', true)', $text);
After add:
$text = preg_replace('#\[img=left\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e', 'handle_img_tag_left(\'$1$3\', true)', $text);
$text = preg_replace('#\[img=right\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e', 'handle_img_tag_right(\'$1$3\', true)', $text);
Open the CSS files you want to add the floating-images feature to.
Add:
IMG.postimg_left {float:left;margin:4px;clear:left}
IMG.postimg_right{float:right;margin:4px;clear:right}
IMG.sigimage_left{float:left;margin:4px;clear:left}
IMG.sigimage_right{float:right;margin:4px;clear:right}
Now all you have to do is type [ img = <left or right> ] <image url> [ / img ] (without the spaces of course ;))