Magento change product image on hover in catalog page

If you want to show thumbnail image on mouse over & after mouse out show small image then go through :

app->design->frontend->default->your theme->template->catalog->product->list.pthml

in this Search this code:

<a href=”<?php echo $_product->getProductUrl() ?>” title=”<?php echo $this->stripTags($this->getImageLabel($_product, ‘small_image’), null, true) ?>”><img src=”<?php echo $this->helper(‘catalog/image’)->init($_product, ‘small_image’)->resize(135); ?>” width=”135″ height=”135″ alt=”<?php echo $this->stripTags($this->getImageLabel($_product, ‘small_image’), null, true) ?>” /></a>

in place of that put this code :-

<a href=”<?php echo $_product->getProductUrl() ?>” title=”<?php echo $this->stripTags($this->getImageLabel($_product, ‘small_image’), null, true) ?>”><img src=”<?php echo $this->helper(‘catalog/image’)->init($_product, ‘small_image’)->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(135); ?>” width=”135″ height=”135″ alt=”<?php echo $this->stripTags($this->getImageLabel($_product, ‘small_image’), null, true) ?>” onmouseover=”this.src='<?php echo $this->helper(‘catalog/image’)->init($_product, ‘thumbnail’)->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(135) ?>’;” onmouseout=”this.src='<?php echo $this->helper(‘catalog/image’)->init($_product, ‘small_image’)->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(135) ?>’;” />

Now in admin assign different image for thumbnail and small image. thumbnail image will show when you mouse over on product image.

Advertisements

3 thoughts on “Magento change product image on hover in catalog page

  1. Hi, this works great only on the iPhone the images has now a wrong ratio. Also the image doesn’t flip when touching the image.. Anyone knows another solution? Thanks Chndr

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s