I have a list of images showing and each image got a list of 1 or more additional thumbnail images.
When use hovers on one of the additonal images, the main image has to change with that addional image's source, and when mouse leaves that thumbnail, the original main image source comes back.
I managed to make it work but it only updates the source with the last thumnbail in found in the loop, so I'm basically stuck here is my code which is not working at the moment
<div>
<img class="mainImg" src="http://mysource.com/img.jpg"/>
</div>
<div class="additionalImg">
<?php
$product = Mage::getModel('catalog/product')->load($_product->getId());
/* getting additional images url */
foreach ($product->getMediaGalleryImages() as $image) {?>
<!-- thumbnails -->
<a href="<?php echo $image->getUrl();?>">
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail', $image->getFile())->resize(60, 60); ?>"
width="60" height="60" alt="" title="" />
</a>
<!-- end thumbnails -->
<script>
// var newSrc = jQuery('.additionalImg a img').attr('src');
jQuery('.additionalImg a').hover(function(){
jQuery('.mainImg').attr("src", newSrc)
});
</script>
<?php };?>
</div>
Thanks a lot