Skip to content

Instantly share code, notes, and snippets.

@kpodemski
Last active April 29, 2016 18:15
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kpodemski/6422098 to your computer and use it in GitHub Desktop.
Save kpodemski/6422098 to your computer and use it in GitHub Desktop.
PrestaShop rollover images solution
<img class="rollover-images" data-rollover="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default', $product.id_product)}" src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}" alt="{$product.name|escape:html:'UTF-8'}" />
<script>
function makeRolloverImages()
{
$(function() {
$('.rollover-images').each(function()
{
var newSrc = $(this).data('rollover');
if(newSrc == 0) return;
var oldSrc;
$(this).hover(function()
{
oldSrc = $(this).attr('src');
$(this).attr('src', newSrc).stop(true,true).hide().fadeIn('slow');
}, function()
{
$(this).attr('src', oldSrc).stop(true,true).hide().fadeIn('slow');
});
});
});
}
makeRolloverImages();
</script>
@umair89
Copy link

umair89 commented Feb 19, 2015

thanks for the solution its working fine but their is a problem when i place the mouse on image it change the image but when i place out the mouse from the image . it not return to a first image which was present before the mouse hover kindly give me the solution to solve this issue its very urgent for me. Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment