MyBB Community Forums

Full Version: MyBB 1.1.1 Image Resize
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm using javascript code to resize images (created by msone). How can I get this javascript to work with the updated functions_post.php?

Code from 1.1.0 using javascript:
if($allowimgcode)
	{
		$message = preg_replace("#\[img\]([a-z]+?://){1}(.+?)\[/img\]#i", "<img src=\"$1$2\" border=\"0\" alt=\"\" onload=\"if(largerThan(this.width,500)) {this.width=500;this.alt='Click for full version';}\" onmouseover=\"if(this.alt) this.style.cursor='pointer';\" onclick=\"if(this.alt) window.open('$1$2');\" border=\"0\" />", $message);
		$message = preg_replace("#\[img=([0-9]{1,3})x([0-9]{1,3})\]([a-z]+?://){1}(.+?)\[/img\]#i", "<img src=\"$3$4\" style=\"border: 0; width: $1px; height: $2px;\" alt=\"\" />", $message);
	}

Code from 1.1.1 without javascript:
if($allowimgcode)
	{
		$message = preg_replace("#\[img\](https?://([^<>\"']+))\[/img\]#i", "<img src=\"$1\" border=\"0\" alt=\"\" />", $message);
		$message = preg_replace("#\[img=([0-9]{1,3})x([0-9]{1,3})\](https?://([^<>\"']+))\[/img\]#i", "<img src=\"$3\" style=\"border: 0; width: $1px; height: $2px;\" alt=\"\" />", $message);
	}

The header includes this code:
<script type="text/javascript">
function largerThan(a,b)
{
return a>b;
}
</script>
Replace
([a-z]+?://){1}(.+?)

With
(https?://([^<>\"']+?))

In both of the $message = preg_replace... lines.
Thanks
It actually seems to be doubling the img urls (but only one http://). Example:
http://www.website.com/image.jpgwww.website.com/image.jpg

The code in my functions_post.php is:
if($allowimgcode)
{
	$message = preg_replace("#\[img\](https?://([^<>\"']+?))\[/img\]#i", "<img src=\"$1$2\" border=\"0\" alt=\"\" onload=\"if(largerThan(this.width,500)) {this.width=500;this.alt='Click for full version';}\" onmouseover=\"if(this.alt) this.style.cursor='pointer';\" onclick=\"if(this.alt) window.open('$1$2');\" border=\"0\" />", $message);
	
$message = preg_replace("#\[img=([0-9]{1,3})x([0-9]{1,3})\](https?://([^<>\"']+?))\[/img\]#i", "<img src=\"$3$4\" style=\"border: 0; width: $1px; height: $2px;\" alt=\"\" />", $message);
	}
Ah sorry.

[code]if($allowimgcode)
{
$message = preg_replace("#\[img\](https?://([^<>\"']+?))\[/img\]#i", "<img src=\"$1\" border=\"0\" alt=\"\" onload=\"if(largerThan(this.width,500)) {this.width=500;this.alt='Click for full version';}\" onmouseover=\"if(this.alt) this.style.cursor='pointer';\" onclick=\"if(this.alt) window.open('$1$2');\" border=\"0\" />", $message);

$message = preg_replace("#\[img=([0-9]{1,3})x([0-9]{1,3})\](https?://([^<>\"']+?))\[/img\]#i", "<img src=\"$3\" style=\"border: 0; width: $1px; height: $2px;\" alt=\"\" />", $message);
}[/code[