regex - Preg Replace of image source but not image link in PHP -
i have content in cms database, images have click zoom plugin.
the html markup image looks this
<div class="large-image-outer"> <a class="fancybox-button zoomer" data-rel="fancybox-button" title="" href="http://images.website.com/prams/folder/e3-v2/review/e3-v2-introduction-1.jpg"> <div class="overlay-zoom"><img class="large-image img-polaroid" src="http://images.website.com/prams/folder/e3-v2/review/e3-v2-introduction-1.jpg" alt="" title="" /> <div class="zoom-icon"></div> </div> </a> </div>
i'm trying go through database , replace images on page thumbnails. each thumbnail named same image, -thumbnail.jpg on end. in example above
<img class="large-image img-polaroid" src="http://images.website.com/prams/folder/e3-v2/review/e3-v2-introduction-1.jpg" alt="" title="" />
should replaced
<img class="large-image img-polaroid" src="http://images.website.com/prams/folder/e3-v2/review/e3-v2-introduction-1-thumbnail.jpg" alt="" title="" />
how can php - i'm assuming preg replace answer, it's tricky because need
only replace image file name in tag not link full size image in tag.
append "-thumbnail.jpg" regardless of whether image png or jpg file (all of thumbnails jpg, of full size images png.
thanks
some regex here
preg_replace('/src\=\"(.*?)\.(jpg|png)\"/', 'src="$1-thumbnail.$2"');
Comments
Post a Comment