Last active
February 10, 2021 21:10
-
-
Save PechenkiUA/b1c9a8f7536a2abc7764aeb8ed0deb4b to your computer and use it in GitHub Desktop.
add to image is galery product
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'woocommerce_before_shop_loop_item_title', function(){ | |
if (is_user_logged_in()) { | |
global $product; | |
$attachment_ids = $product->get_gallery_image_ids(); | |
$attr = ['class'=>'to-image']; | |
echo wp_get_attachment_image(reset($attachment_ids), 'shop_catalog',false, $attr); | |
} | |
}, 10 ); | |
/* css | |
.woocommerce-LoopProduct-link { | |
position: relative; | |
} | |
.to-image { | |
position: absolute; | |
top: 0; | |
opacity: 0; | |
transition: .5s; | |
} | |
.woocommerce-LoopProduct-link:hover .to-image{ | |
opacity: 1; | |
transition: .5s; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment