adrianbj
05-08-2009, 04:30 AM
Can someone please help me to clean this up. This works, but there has to be a nicer way to do it. The goal is to create popup links to images uploaded through out CMS, except for ones that have class="nopopup" applied to them. So, the first line puts things together to look like imgclass="nopopup". The second line changes img tags with this to <noimg so that next line which creates the popups won't do anything to these img tags. The final line converts the <noimg back to <img so that the image will actually be displayed.
Would really appreciate some help simplifying this.
$content = preg_replace('/<img(.*?)(class="nopopup")(.*?)>/i', '<img$2$1$3>', $content);
$content = str_replace('<imgclass="nopopup"','<noimg',$content);
$content = preg_replace('/<img(.*?)src="(.*?)\.(.*?)"(.*?)>/i', '<a href="$2_lge.$3" class="highslide" onclick="return hs.expand(this)" onmouseover="Tip(\'Click to Enlarge\', WIDTH, 0)" onmouseout="UnTip()"><img src="$2.$3" $1 $4></a>', $content);
$content = str_replace('<noimg','<img',$content);
Would really appreciate some help simplifying this.
$content = preg_replace('/<img(.*?)(class="nopopup")(.*?)>/i', '<img$2$1$3>', $content);
$content = str_replace('<imgclass="nopopup"','<noimg',$content);
$content = preg_replace('/<img(.*?)src="(.*?)\.(.*?)"(.*?)>/i', '<a href="$2_lge.$3" class="highslide" onclick="return hs.expand(this)" onmouseover="Tip(\'Click to Enlarge\', WIDTH, 0)" onmouseout="UnTip()"><img src="$2.$3" $1 $4></a>', $content);
$content = str_replace('<noimg','<img',$content);