drisate Posted December 16, 2008 Share Posted December 16, 2008 Hey guys. I am currently using an old version of the joomlaboard made out a very very old version of the simple machine forum. That board currently has a very basic bbcode feature. One thing that annoys me allot is that members can use the tag but when it's larger then 430px it breaks the webpage layout. What i would like to do is find a way to detect the size and max it at 430 This is what the code looks like: messageString = messageString.replace(/\[img size=([1-4][0-9][0-9])\](.*?)\[\/img\]/g,"<img src=\"$2\" border\"0\" alt=\"\" width=\"$1"\">"); messageString = messageString.replace(/\[img\](.*?)\[\/img\]/g,"<img src=\"$1\" border\"0\" alt=\"\" />"); I can do this in PHP but Javascript is beyond my comprehension ... From what i understand the first one use $1 as the size value so if ($1>'"430") $i="430" How can i put that in there? In the second part, we don't have the size value but the image source. So we need to extract the width of the image and if it's bigger than 430 restrict it to 430. But again, how to do i do that in javascript? the full code look like this: messageString = messageString.replace(/\[img size=([1-4][0-9][0-9])\](.*?)\[\/img\]/g,"<img src=\"$2\" border\"0\" alt=\"\" width=\"$1"\">"); messageString = messageString.replace(/\[img\](.*?)\[\/img\]/g,"<img src=\"$1\" border\"0\" alt=\"\" />"); messageString = messageString.replace(/(\[url\])(.*?)(\[\/url\])/g,"<a href=$2 target=\"_blank\">$2</a>"); messageString = messageString.replace(/\[url=(.*?)\](.*?)\[\/url\]/g,"<a href=\"$1\" target=\"_blank\">$2</a>"); messageString = messageString.replace(/\[size=([1-7])\](.+?)\[\/size\]/g,"<font size=\"$1\">$2</font>"); messageString = messageString.replace(/\[color=(.*?)\](.*?)\[\/color\]/g,"<span style=\"color: $1\">$2</span>"); messageString = messageString.replace(/\[file name=(.*?) size=(.*?)\](.*?)\[\/file\]/g,"<div class=\"sb_file_attachment\"><span class=\"contentheading\">File Attachment:</span><br>File name: <a href=\"$3\">$1</a><br>File size:$2 bytes</div>"); Quote Link to comment Share on other sites More sharing options...
ComGuar Posted December 22, 2008 Share Posted December 22, 2008 I think there is some scripts for image manipulation here http://javascript.internet.com Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.