PDA

View Full Version : <img src=images/image.gif align=right>


Ninth Dimension
04-06-2002, 01:09 PM
Hi all, I need a BB code that will align an image to the right (or left, or whatever) can someone help me out please? Thanx :)

Admin
04-06-2002, 01:18 PM
Create a new BB code, call it imgalign, Use {option} and enter this in the replacement:
<img src="{param}" align="{option}">

Ninth Dimension
04-06-2002, 01:26 PM
Perfect, thank you Fly-o-Fire :)

Admin
04-06-2002, 01:29 PM
Ok, you'll like this better. In functions.php add:
$bbcode = preg_replace("/(\[)(img)=([^\]]*)(])(\r\n)*([^\"".iif($allowdynimg,"","\?\&")."]*)(\[\/img\])/siU", "<img src=\"\\6\" align=\"\\3\" border=\"0\" alt=\"\">", $bbcode);
right after:
$bbcode = preg_replace("/(\[)(img)(])(\r\n)*([^\"".iif($allowdynimg,"","\?\&")."]*)(\[\/img\])/siU", "<img src=\"\\5\" border=\"0\" alt=\"\">", $bbcode);
Now people can use http://www... to align their picture to the center. :)

Ninth Dimension
04-06-2002, 01:38 PM
Cool, thank you :) you can see this in action at both http://savepoint.co.uk/ and http://bbs.ofdan.net/showthread.php?s=&threadid=113

(I can see myself using this quote a lot)

Admin
04-06-2002, 01:43 PM
Ok, I found a better way to do this without another preg_replace().

Replace this:
$bbcode = preg_replace("/(\[)(img)(])(\r\n)*([^\"".iif($allowdynimg,"","\?\&")."]*)(\[\/img\])/siU", "<img src=\"\\5\" border=\"0\" alt=\"\">", $bbcode);
With this:
$bbcode = preg_replace("/(\[)(img)(=([^\]]*))?(])(\r\n)*([^\"".iif($allowdynimg,"","\?\&")."]*)(\[\/img\])/siU", "<img src=\"\\7\" align=\"\\4\" border=\"0\" alt=\"\">", $bbcode);
(and undo my original change)

Ninth Dimension
04-06-2002, 01:52 PM
Perfect FireFly, will you marry me? :)