Calling a second image URL to realize image change function on mouseover in Magento

To get OnMouseOver to change the image and show the default thumbnail in the product grid or list views, add the following code to the list.phtml file of your theme:

<a href="getProductUrl() ?>" title="stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="helper('catalog/image')->init($_product, 'small_image')->keepAspectRatio(false); ?>" width="270" height="270" alt="stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" onmouseover="this.src='helper('catalog/image')->init($_product, 'thumbnail')->keepAspectRatio(false); ?>';"onmouseout="this.src='helper('catalog/image')->init($_product, 'small_image')->keepAspectRatio(false); ?>';" />


Leave a Reply

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

You are commenting using your 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