the problem with your way is if a post full of text has an image in it, it removes the entire post's content from the guests view instead of just the image... which isnt good.
this is what i use for my forum:
open functions_bbcodeparse.php and find:
PHP Code:
// do [img]https://vborg.vbsupport.ru/[/img]
$bbcode = preg_replace('#\[img\]\s*(https?://([^<>*"' . iif(!$vboptions['allowdynimg'], '?&') . ']+|[a-z0-9/\\._\- !]+))\[/img\]#iUe', "handle_bbcode_img_match('\\1')", $bbcode);
replace with:
PHP Code:
// do [img]https://vborg.vbsupport.ru/[/img]
if($bbuserinfo[userid]== 0) {
// replace image with error for guests.
$bbcode = preg_replace("|\[img\](.*)\[/img\]|i", "<a href=\"http://www.your-url-here.com/register.php\"><div class=\"panel\" style=\"width:500px;\"><strong>ERROR: </strong>Guests may not view user posted images. Click here to join our forum!</div></a>", $bbcode);
} else {
// members get to see the image.
$bbcode = preg_replace('#\[img\]\s*(https?://([^<>*"' . iif(!$vboptions['allowdynimg'], '?&') . ']+|[a-z0-9/\\._\- !]+))\[/img\]#iUe', "handle_bbcode_img_match('\\1')", $bbcode);
}
(dont forget to replace 'your-url-here' with your forum's url)