guide to add zoom on image hove functionality on my product page. I added the zoom.min.js file to my theme and I edited my media.liquid file to look like this:(code at end of file)
But now when I open my product page it’s just a blank square, seems like the plugin is not working at all. Any idea what I did wrong? Thanks
{% comment %}
Renders a media element for the product gallery.
Media types include: image, video, external_video and model.
Accepts:
- media: {Object} Media Liquid object (required)
- enable_image_zoom: {Boolean} Image zoom setting (required for media type image)
- stacked: {Boolean} Layout type set as stacked (required)
- featured: {Boolean} Media is set as featured (required)
- height: {Number} Height to be passed to the image-style snippet
- width: {Number} Width to be passed to the image-style snippet
Usage:
{%- for media in product.media -%}
{% include 'media', media: media, enable_image_zoom: true, featured: true, stacked: true %}
{%- endfor -%}
{% endcomment %}
{% capture media_id %}{{ section.id }}-{{ media.id }}{% endcapture %}
{% capture img_id_class %}product-single__media-{{ media_id }}{% endcapture %}
{% capture wrapper_id %}ProductMediaWrapper-{{ media_id }}{% endcapture %}
{% capture image_size %}{{ height }}x{{ height }}{% endcapture %}
{% case media.media_type %}
{% when 'image' %}
{% include 'image-style' with image: media, width: width, height: height, small_style: true, wrapper_id: wrapper_id, img_id_class: img_id_class %}
{% assign img_url = media | img_url: '1x1' | replace: '_1x1.', '_{width}x.' %}
{% when 'external_video' %}
{{ media | external_video_tag }}
{% when 'video' %}
{{ media | video_tag: controls: false, class: 'media-video', image_size: image_size }}
{% when 'model' %}
{{ media | model_viewer_tag: image_size: image_size, reveal: 'interaction', toggleable: true, data-model-id: media.id}}
{% else %}
{{ media | media_tag: class: 'media-item', image_size: image_size }}
{% endcase %}
I’m sorry I don’t know what exactly you mean. I followed the steps exactly one by one, but the linked article was talking about modifying the product.liquid code, but that’s not where my product images code is, so I had to manually find the code where product image is.
This worked very well thank you very much! I am facing a problem now that the entire image gets show even though I only want the part where the mouse is to zoom in. If you look at the linked article there is a example of that exact behavior. Would you be able to help me with that too? But thank you very much!
If needed, here is my current code:
{% comment %}
Renders a media element for the product gallery.
Media types include: image, video, external_video and model.
Accepts:
- media: {Object} Media Liquid object (required)
- enable_image_zoom: {Boolean} Image zoom setting (required for media type image)
- stacked: {Boolean} Layout type set as stacked (required)
- featured: {Boolean} Media is set as featured (required)
- height: {Number} Height to be passed to the image-style snippet
- width: {Number} Width to be passed to the image-style snippet
Usage:
{%- for media in product.media -%}
{% include 'media', media: media, enable_image_zoom: true, featured: true, stacked: true %}
{%- endfor -%}
{% endcomment %}
{% capture media_id %}{{ section.id }}-{{ media.id }}{% endcapture %}
{% capture img_id_class %}product-single__media-{{ media_id }}{% endcapture %}
{% capture wrapper_id %}ProductMediaWrapper-{{ media_id }}{% endcapture %}
{% capture image_size %}{{ height }}x{{ height }}{% endcapture %}
{% case media.media_type %}
{% when 'image' %}
{% include 'image-style' with image: media, width: width, height: height, small_style: true, wrapper_id: wrapper_id, img_id_class: img_id_class %}
{% assign img_url = media | img_url: '1x1' | replace: '_1x1.', '_{width}x.' %}
{% when 'external_video' %}
{{ media | external_video_tag }}
{% when 'video' %}
{{ media | video_tag: controls: false, class: 'media-video', image_size: image_size }}
{% when 'model' %}
{{ media | model_viewer_tag: image_size: image_size, reveal: 'interaction', toggleable: true, data-model-id: media.id}}
{% else %}
{{ media | media_tag: class: 'media-item', image_size: image_size }}
{% endcase %}
Hi @dggb . I see that you have resolved the issue on your website. Can you help me with the same? I have followed all the steps and I am facing the same issue that you were facing. When I hover over the image the image just gets enlarged to the whole screen. Can you tell me how to limit the zoomed image to the box you have in your website? And how do we create that zoomed image listener?
Thank you for your response. Though I cannot find the “Product pages” tab after clicking on customize. Can you help ? Below is what I get after clicking customize.
Now if you want the enlarged image to appear in a window on the side, you must use the jquery-zoom target option, write me if you need help noranterri@gmail.com