Skip to content

Instantly share code, notes, and snippets.

@artboard-studio
Created September 22, 2013 14:45
Show Gist options
  • Save artboard-studio/6660612 to your computer and use it in GitHub Desktop.
Save artboard-studio/6660612 to your computer and use it in GitHub Desktop.
update woocommerce main product image on thumbnail click
jQuery(document).ready(function($) {
"use strict";
$(document).on('click','.thumbnails .zoom', function(){
var photo_fullsize = $(this).find('img').attr('src').replace('-150x180','');
$('.woocommerce-main-image img').attr('src', photo_fullsize);
return false;
});
});
@marcelo2605
Copy link

@CapitalH @arshidkv12

This worked for me in WordPress 4.6

    $('body').on('click','.thumbnails img', function(){
        var thumb_fullsize = $(this).attr('src').replace('-180x180','');
            thumb_srcset = $(this).attr('srcset');

        $('.images > img').attr('src', thumb_fullsize);
        $('.images > img').attr('srcset', thumb_srcset);
        return false;
    });

@vshah9
Copy link

vshah9 commented Sep 23, 2016

@marcelo2605
where should I enter your code? should I make one new file of js?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment