Jump to content

Change product image on Click instead of Mouseover


Recommended Posts

It looks like it is the following code on lines 347-351 of product.js (in PrestaShop v1.3.1) that does the hover effect:

//hover 'other views' images management
$('#views_block li a').hover(
   function(){displayImage($(this));},
   function(){}
);



Change it to the following to make it a click event instead of a hover event:

//hover 'other views' images management
$('#views_block li a').click(
   function(){displayImage($(this));}
);



The only problem is that you now have two click event. One that does the hover effect and one that displays the thickbox image. Both will happen at the same time now. To remove the thickbox popup, change line 118 (in PrestaShop v1.3.1) of product.tpl in your theme's directory from:

<a href="{$link->getImageLink($product->link_rewrite, $imageIds, 'thickbox')}" rel="other-views" class="thickbox {if $smarty.foreach.thumbnails.first}shown{/if}" title="{$image.legend|htmlspecialchars}">



to:

<a href="{$link->getImageLink($product->link_rewrite, $imageIds, 'thickbox')}" onclick="return false" title="{$image.legend|htmlspecialchars}">

  • Like 4
Link to comment
Share on other sites

I've had a closer look at this. It turns out that it's impossible to have the thickbox work for the big image for not for the thumbnail images. I've tried everything I can think of, but nothing worked. The only solution is to disable thickbox altogether. I've updated my code above.

Link to comment
Share on other sites

  • 3 months later...
  • 3 months later...
  • 1 year later...
  • 6 months later...
  • 3 months later...

Mr. Rocky any idea for keeping the mouseover but with a SetTimeOut of 2 seconds? I'm thinking that mouseover is kept and if a visitor keeps the mouse over a thumbnail for a period of 2 seconds then the bigimage is changed, otherwise nothing happens... i think this may be a solution because when there are a lot of thumbnails and they are displayed in a row, a visitor may accidently mouseover another thumbnail if he tries to go with the mouse on the big pic for the zoom efect.... what do you say?

Link to comment
Share on other sites

  • 3 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...