I want to add a rel=lightbox to every <a href="">
including an image .
<a href=""><img src="" alt="" title="" border="" /></a>
to
<a href="" rel="lightbox"><img src="" alt="" title="" border="" /></a>
And to make this i wrote the following php code :
$var1= $rows['article'];
$var1= str_replace('<br>', '<br />', $var1);
$var1 = str_replace('align="none"', '', $var1);
$var1 = str_replace('target=""', 'target="_self"', $var1);
$var2= preg_replace( '~<img\s[^>]*\K(?<!/)>~', "/>", $var1);
$var2= preg_replace('~<a(?=[^>]+>\s*<img)~','<a rel="lightbox"',$var2);
echo $var2;
The code before is doing the job, but in the case that i want to link an image not to an other image but to a url link then i have problem beacuse when is trying to open the url link actually the lightbox effect loads !
I want to modify it so when i link to a url link to dont apply the lightbox effect in this case.
But how can i make this, can you help me pleaaase ?
Thanks a lot