I have some content in a CMS database, where all images have a click to zoom plugin.
The HTML markup for an image looks like 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 to go through the database and replace all images on the page with thumbnails. Each thumbnail is named the same as the image, but with -thumbnail.jpg on the end. So in the 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 be replaced with
<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 I do this with PHP - I'm assuming preg replace is the answer, but it's tricky because I need to
Only replace the image file name in the tag not the link to the full size image in the tag.
append "-thumbnail.jpg" regardless of whether the image is a png or jpg file (all of the thumbnails are jpg, but some of the full size images are png.
Thanks