MyBB Community Forums

Full Version: image for reg and unreg
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How to make:
1. normal visible image view for member
2. only a sign view like this:[Image: jpg.gif] for unregistered member
I assume you are talking about post images.
Open ./inc/class_parser.php

Find
	function mycode_parse_img($url, $dimensions=array(), $align='')
	{
		$url = trim($url);
		$url = str_replace("\n", "", $url);
		$url = str_replace("\r", "", $url);
		if($align == "right")
		{
			$css_align = " style=\"float: right;\"";
		}
		else if($align == "left")
		{
			$css_align = " style=\"float: left;\"";
		}
		if($dimensions[0] > 0 && $dimensions[1] > 0)
		{
			return "<img src=\"{$url}\" width=\"{$dimensions[0]}\" height=\"{$dimensions[1]}\" border=\"0\" alt=\"\"{$css_align} />";
		}
		else
		{
			return "<img src=\"{$url}\" border=\"0\" alt=\"\"{$css_align} />";			
		}
	}
replace with
	function mycode_parse_img($url, $dimensions=array(), $align='')
	{
		global $mybb;
		if($mybb->user['uid'] > 0)
		{
			$url = trim($url);
			$url = str_replace("\n", "", $url);
			$url = str_replace("\r", "", $url);
			if($align == "right")
			{
				$css_align = " style=\"float: right;\"";
			}
			else if($align == "left")
			{
				$css_align = " style=\"float: left;\"";
			}
			if($dimensions[0] > 0 && $dimensions[1] > 0)
			{
				return "<img src=\"{$url}\" width=\"{$dimensions[0]}\" height=\"{$dimensions[1]}\" border=\"0\" alt=\"\"{$css_align} />";
			}
			else
			{
				return "<img src=\"{$url}\" border=\"0\" alt=\"\"{$css_align} />";			
			}
		}
		else
		{
			return "<img src=\"icons.gif\" border=\"0\" alt=\"\" />";
		}
	}

Change icons.gif to the name and path of your custom icon.
Thank you, i'l try first. do you have /know forum that use this script or any others?
zaher1988 Wrote:I assume you are talking about post images.
Open ./inc/class_parser.php

Find
	function mycode_parse_img($url, $dimensions=array(), $align='')
	{
		$url = trim($url);
		$url = str_replace("\n", "", $url);
		$url = str_replace("\r", "", $url);
		if($align == "right")
		{
			$css_align = " style=\"float: right;\"";
		}
		else if($align == "left")
		{
			$css_align = " style=\"float: left;\"";
		}
		if($dimensions[0] > 0 && $dimensions[1] > 0)
		{
			return "<img src=\"{$url}\" width=\"{$dimensions[0]}\" height=\"{$dimensions[1]}\" border=\"0\" alt=\"\"{$css_align} />";
		}
		else
		{
			return "<img src=\"{$url}\" border=\"0\" alt=\"\"{$css_align} />";			
		}
	}
replace with
	function mycode_parse_img($url, $dimensions=array(), $align='')
	{
		global $mybb;
		if($mybb->user['uid'] > 0)
		{
			$url = trim($url);
			$url = str_replace("\n", "", $url);
			$url = str_replace("\r", "", $url);
			if($align == "right")
			{
				$css_align = " style=\"float: right;\"";
			}
			else if($align == "left")
			{
				$css_align = " style=\"float: left;\"";
			}
			if($dimensions[0] > 0 && $dimensions[1] > 0)
			{
				return "<img src=\"{$url}\" width=\"{$dimensions[0]}\" height=\"{$dimensions[1]}\" border=\"0\" alt=\"\"{$css_align} />";
			}
			else
			{
				return "<img src=\"{$url}\" border=\"0\" alt=\"\"{$css_align} />";			
			}
		}
		else
		{
			return "<img src=\"icons.gif\" border=\"0\" alt=\"\" />";
		}
	}

Change icons.gif to the name and path of your custom icon.
dyota Wrote:Thank you, i'l try first. do you have /know forum that use this script or any others?

No on has asked this before as far as i know. I have coded and tested that yesterday. You can try it on a localhosted website in case you are afraid.