I need to duplicate the image file and add it after with making a slight change to the file name.
The problem I am having is the var does not change with each image. This will have to run for many more images so I have to find a way to update the var for each image.
<a class="slashc-img-zoom-pan">
<img src="/v/vspfiles/photos/hk01344-1478-1.jpg">
</a>
<a class="slashc-img-zoom-pan">
<img src="/v/vspfiles/photos/sc-00342-1.jpg">
</a>
<a class="slashc-img-zoom-pan">
<img src="/v/vspfiles/photos/bs-0034-534-1.jpg">
</a>
<script>
$('a img').each(function() {
var image_sku = $("a").html().split("-1.jpg")[0];
$(this).after(image_sku + '-2.jpg" >');
});
</script>
The outcome is suppose to look like this:
<a class="slashc-img-zoom-pan">
<img src="/v/vspfiles/photos/hk01344-1478-1.jpg">
<img src="/v/vspfiles/photos/hk01344-1478-2.jpg">
</a>
<a class="slashc-img-zoom-pan">
<img src="/v/vspfiles/photos/sc-00342-1.jpg">
<img src="/v/vspfiles/photos/sc-00342-2.jpg">
</a>
<a class="slashc-img-zoom-pan">
<img src="/v/vspfiles/photos/bs-0034-534-1.jpg">
<img src="/v/vspfiles/photos/bs-0034-534-2.jpg">
</a>
This does it with jQuery.
http://jsfiddle.net/jasongennaro/TUzNF/3/
Explanation:
a