Created
January 3, 2018 03:40
-
-
Save vosters/0d40ad50d9c59dfe9f1d3883323144e3 to your computer and use it in GitHub Desktop.
Display 2nd product image on hover within Shopify collection loop
This file contains hidden or 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
<a href="{{ product.url | within: collection }}" class="grid__image" {% if template == 'product' %}onclick="ga('send', 'event', 'Related Products', 'Clicked Related Product - {{ product.type }}', '{{ product.title }}');"{% elsif template == 'index' %}onclick="ga('send', 'event', 'Homepage Products', 'Clicked Best Sellers - {{ product.title }}');"{% endif %}> | |
{% if product.images.size > 1 %} | |
<img src="{{ product.images[0] | product_img_url: 'large' }}" alt="{{ product.title | escape }}" /> | |
<img src="{{ product.images[1] | product_img_url: 'large' }}" alt="{{ product.title | escape }}" style="display:none" /> | |
{% else %} | |
<img src="{{ product.featured_image.src | img_url: 'large' }}" alt="{{ product.featured_image.alt | escape }}"> | |
{% endif %} | |
</a> |
This file contains hidden or 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
.product-grid a:hover img:last-child { | |
display: block !important; | |
} | |
.product-grid a:hover img:first-child { | |
display: none; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment