For some reason, the code I'm using does not seem to load unless I inspect and run a debug. Perhaps someone else can review and make sure?
While the first check makes sure it's a product page, I would like a secondary check making sure the product has a gallery and if not - return.
This is the code:
add_action( 'wp_footer', 'image_swap_on_hover' );
function image_swap_on_hover() {
if ( ! is_product() ) return;
// if (???) // check if product has image gallery
?>
<script>
jQuery( document ).ready( function($) {
$( window ).load( function() {
$( '.flexslider' ).flexslider( {
animation: "slide",
controlNav: "thumbnails",
start: function() {
}
}
);
$( ".flex-control-thumbs li img" ).hover( function() {
$(this).click();
}
);
}
);
}
);
</script>
<?php
}