I have been trying for awile now to get a piece of code that will alter a string add add 'Colorbox' links to any image in a string.
I am pulling a simple query from the database, and any image in the string, I want to add a link to it. I have it working however I am getting a /> after each image.
I have it working, you can see it here:
http://goderichport.ca/Port_Corporation/index.php?page=News&&nid=45
You will see the bottom 3 images display properly with the added links, however I get a weird ' /> ' after each image.
Heres my PHP code:
$img_content = $row_Content['content'];
$new_content = preg_replace('~<img\b[^>]+\bsrc\s?=\s?([\'"])(.*?)\1~is', '<a href="$2" rel="colorbox"><img src="$2" border="1" title="Click to View" ></a>', $img_content);
echo $new_content;
Can someone see my error here? Its working I just need the /> gone after each image.
Thanks so much!
Jim