Last active
March 4, 2024 17:28
-
-
Save dpw1/8369f676fda79f52d6c9f29ae7137e0d to your computer and use it in GitHub Desktop.
Choose which image to show on hover (instead of the second one)
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
{% assign second_image_number = 3 %} | |
{% assign image_to_show = second_image_number | minus:1 %} | |
{% assign ezfy_image_on_hover = card_product.media[image_to_show] %} | |
<img | |
srcset=" | |
{%- if ezfy_image_on_hover.width >= 165 -%}{{ ezfy_image_on_hover | image_url: width: 165 }} 165w,{%- endif -%} | |
{%- if ezfy_image_on_hover.width >= 360 -%}{{ ezfy_image_on_hover | image_url: width: 360 }} 360w,{%- endif -%} | |
{%- if ezfy_image_on_hover.width >= 533 -%}{{ ezfy_image_on_hover | image_url: width: 533 }} 533w,{%- endif -%} | |
{%- if ezfy_image_on_hover.width >= 720 -%}{{ ezfy_image_on_hover | image_url: width: 720 }} 720w,{%- endif -%} | |
{%- if ezfy_image_on_hover.width >= 940 -%}{{ ezfy_image_on_hover | image_url: width: 940 }} 940w,{%- endif -%} | |
{%- if ezfy_image_on_hover.width >= 1066 -%}{{ ezfy_image_on_hover | image_url: width: 1066 }} 1066w,{%- endif -%} | |
{{ ezfy_image_on_hover | image_url }} {{ ezfy_image_on_hover.width }}w | |
" | |
src="{{ ezfy_image_on_hover | image_url: width: 533 }}" | |
sizes="(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 130 | divided_by: 4 }}px, (min-width: 990px) calc((100vw - 130px) / 4), (min-width: 750px) calc((100vw - 120px) / 3), calc((100vw - 35px) / 2)" | |
alt="" | |
class="motion-reduce" | |
loading="lazy" | |
width="{{ ezfy_image_on_hover.width }}" | |
height="{{ ezfy_image_on_hover.height }}" | |
> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment