Skip to content

Instantly share code, notes, and snippets.

@rubensaid
Forked from kpodemski/Link.php
Last active August 29, 2015 14:26
Show Gist options
  • Save rubensaid/cff340d17ffa4358025f to your computer and use it in GitHub Desktop.
Save rubensaid/cff340d17ffa4358025f 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment