php - disable preg_replace() for some images... -
i using function replace data-rel
, add hyperlink
images of content.
function add_image_responsive_class($content) { global $post; $pattern ="~<img(.*?)class=\"(.*?)\"(.*?)src=\"(.*?)\"(.*?)>~i"; $replacement = '<a href="$4" data-rel="lightbox-gallery"><img$1class="$2"$3src="$4"$5></a>'; $content = preg_replace($pattern, $replacement, $content); return $content; } add_filter( 'the_content', 'add_image_responsive_class');
its working awesome, there 1 issue facing now. time want add images have different links. example want add logos link websites. opening same image because of preg_replace()
function.
is there way disable images somehow? cant use link media file every image, that's why using function. please me!
Comments
Post a Comment