Kinetic Pulse
  • Home
  • Services
  • Portfolio
  • Blog
  • Terms
  • Contact

Create smoother mouseover effect on product images using jQuery in Magento UPDATE

February 8, 2011

Well at the insistence of you guys out there I thought I’d post my results for getting a nice smoother mouseover effect using jQuery.

You need to edit the list.phtml in the two places it is pumping out images for the List view & the Grid View.
Copy and past the following code completely over the <a> tag that covers the product image:


<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image">
<img class="small_image" src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(217); ?>" width="147" height="217" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
<img class="thumbnail" src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(217) ?>" width="147" height="217" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
</a>

(Note: As before I am constraining my images to be 217px high for my theme)
This will basically put the thumbnail image directly below the small_image & when you add the following lines to your stylesheet they will be absolutley positioned on top of each other.


.product-image{position:relative}
.product-image img{position:absolute}
.product-image img.small_image{z-index:10}
.product-image img.thumbnail{z-index:1}

Then in the file:
\app\design\frontend\YOURTHEME\default\template\page\html\head.phtml add the following script:


<script type="text/javascript">

jQuery(document).ready(function() {
jQuery("img.small_image").hover(
function() {
jQuery(this).stop().animate({"opacity": "0"}, "slow");
},
function() {
jQuery(this).stop().animate({"opacity": "1"}, "slow");
});

});
</script>

You can see the results here:
http://miminoor.kineticpulse.net/denim.html

With many thanks to this post for the quick inspiration:
http://bavotasan.com/tutorials/creating-a-jquery-mouseover-fade-effect/

Share

Facebook Google+ Twitter Pinterest Email
  1. Michael says

    February 8, 2011 at 6:53 pm

    Wow! You're the best! Thanks a lot!

    Regards,

    Michael

Back to Blog

Testimonials

Thank you guys so much for all that you’ve done helping us to create a really awesome website!! We get such great feedback – everyone loves it & we couldn’t be prouder! Look forward to working with you again soon!
Wild Thyme PlantsWild Thyme Plants
Thanks so much for all your work on this, really appreciated. It’s come on in leaps and bounds since you took over.
Pete KewRedwood Strip Curtains
It’s been fab working with you – we love the site and certainly going to recommend you!
James DaviesThirty Eight Degrees North
I like it.  I like it a lot !!!

 You have interpreted what I wanted to achieve perfectly considering what you have to play with i.e not redoing the whole thing in the process.

Fiona Simmons-MooreSouth Gloucestershire Parents & Carers
Thank you for all of your hard work its looks fab and I am over the moon with it!
Amanda MercerAmanda Mercer Ceramics
Amazing and brilliant, Kinetic Pulse have lifted a dream to reality, Highly recommended and great if you are total novice, they know their stuff…Thanks again
Annie LindridgeSalt Yourself Out
Absolutely fantastically professional web developer – I would highly recommend!!! Thank you so much Kinetic Pulse!
Tania MarstonDoris Designs

Copyright 2026 Kinetic Pulse