首页 > 解决方案 > 如何让 elevateZoom 处理多个图像

问题描述

我只能让 elevateZoom 处理一张图片。因此,当我单击将图像更新为所选图像的缩略图时,缩放不再起作用。

代码:

<div class="product-single__photo--flex-wrapper">
<div class="product-single__photo--flex">
    {% include 'image-style' with image: featured_image, width: 575, height: 850, small_style: true, wrapper_id: wrapper_id, img_id_class: img_id_class %}
    <div id="{{ wrapper_id }}" class="product-single__photo--container product-single__photo--container-thumb">
        <div class="product-single__photo-wrapper" style="padding-top:{{ 1 | divided_by: featured_image.aspect_ratio | times: 100}}%;">
            {% assign img_url = featured_image | img_url: '1x1' | replace: '_1x1.', '_{width}x.' %}
            <img id="zoom_03" class="product-single__photo lazyload {{ img_id_class }}"
              src="{{ featured_image | img_url: '300x300' }}"
                                       data-zoom-image="{{ featured_image | img_url: '1080x1080' }}"
              data-src="{{ img_url }}"
              data-widths="[180, 360, 590, 720, 900, 1080, 1296, 1512, 1728, 2048]"
              data-aspectratio="{{ featured_image.aspect_ratio }}"
              data-sizes="auto"
              {% if section.settings.zoom_enable %}data-mfp-src="{{ featured_image | img_url: '1024x1024' }}"{% endif %}
              data-image-id="{{ featured_image.id }}"
              alt="{{ featured_image.alt | escape }}"
                 data-zoom="{{ featured_image | img_url: '1024x1024', scale: 2 }}">

            <noscript>
                <img id="zoom_03" class="product-single__photo"
                src="{{ featured_image | img_url: 'master' }}"
                data-zoom-image="{{ featured_image | img_url: '1080x1080' }}"
                {% if section.settings.zoom_enable %}data-mfp-src="{{ featured_image | img_url: '1024x1024' }}"{% endif %}
                alt="{{ featured_image.alt | escape }}" data-image-id="{{ featured_image.id }}" data-zoom="{{ featured_image | img_url: '1024x1024', scale: 2 }}">
            </noscript>
            <script>
                $('#zoom_03').ezPlus({
                    zoomType: 'inner',
                    cursor: 'crosshair'
                });
            </script>
        </div>
    </div>
</div

这是在 Shopify 上使用的。一张图片有效,多张无效。关于如何让它发挥作用的任何建议?

此处示例 - https://allsops.myshopify.com/products/zoom-test

标签: javascriptshopify

解决方案


根据上面滴滴的评论。

解决此问题的方法是将其从 id 更改为 class。

我按照 elevateZoom-Plus 网站上的指南进行操作,这不适合我的情况。


推荐阅读