有没有办法让我在bigcartel上使用luna模板在幻灯片上添加图像链接

问题描述 投票:0回答:2

我目前正在使用大型卡特尔网站模板中的 Luna 主题。我想知道是否有任何方法或编码可以用来使幻灯片上的图像可点击。我特别希望它能引导我的客户访问某些产品页面。

javascript hyperlink slideshow bigcartel
2个回答
0
投票

是的!希望这可以帮助! :)

将其复制并粘贴到主页的自定义代码中。更改您想要的产品页面的链接。此外,您可以像我一样通过重复代码来添加更多带有链接的幻灯片。

{% if theme.image_sets.slideshow.size > 0 %}
  <div class="flexslider home-slideshow">
    <ul class="slides">
      {% for image in theme.image_sets.slideshow %}
        <li>
          <a href="LINK GOES HERE 1"><img alt="" srcset="{{ image.url | constrain: 1068 }}, {{ image.url | constrain: 2136 }} 2x" src="{{ image.url | constrain: 1068 }}"></a>
        </li>
        <li>
          <a href="LINK GOES HERE 2"><img alt="" srcset="{{ image.url | constrain: 1068 }}, {{ image.url | constrain: 2136 }} 2x" src="{{ image.url | constrain: 1068 }}"></a>
        </li>
        <li>
          <a href="LINK GOES HERE 3"><img alt="" srcset="{{ image.url | constrain: 1068 }}, {{ image.url | constrain: 2136 }} 2x" src="{{ image.url | constrain: 1068 }}"></a>
        </li>
      {% endfor %}
    </ul>
  </div>
{% endif %}
{% if theme.max_products_per_row == 4 %}
  {% assign product_image_constrain_width = 255 %}
  {% assign product_image_constrain_height = 255 %}
  {% assign product_image_constrain_width_large = product_image_constrain_width | times: 2 %}
  {% assign product_image_constrain_height_large = product_image_constrain_height | times: 2 %}
{% elsif theme.max_products_per_row == 3 %}
  {% assign product_image_constrain_width = 346 %}
  {% assign product_image_constrain_height = 346 %}
  {% assign product_image_constrain_width_large = product_image_constrain_width | times: 2 %}
  {% assign product_image_constrain_height_large = product_image_constrain_height | times: 2 %}
{% elsif theme.max_products_per_row == 2 %}
  {% assign product_image_constrain_width = 526 %}
  {% assign product_image_constrain_height = 526 %}
  {% assign product_image_constrain_width_large = product_image_constrain_width | times: 2 %}
  {% assign product_image_constrain_height_large = product_image_constrain_height | times: 2 %}
{% elsif theme.max_products_per_row == 1 %}
  {% assign product_image_constrain_width = 1068 %}
  {% assign product_image_constrain_height = 1068 %}
  {% assign product_image_constrain_width_large = product_image_constrain_width | times: 2 %}
  {% assign product_image_constrain_height_large = product_image_constrain_height | times: 2 %}
{% endif %}
{% assign thumb_constrain_width = 30 %}
{% assign thumb_constrain_height = 30 %}

<h1 class="visually-hidden">Featured Products</h1>
{% if theme.featured_items > 0 %}
  {% get products from products.all limit:theme.featured_items order:theme.featured_order %}
    {% if products != blank %}
      <div class="product-list-container">
        <div class="product-list">
          {% for product in products %}
            {% assign product_status = '' %}
            {% case product.status %}
              {% when 'active' %}
                {% if product.on_sale %}{% assign product_status = 'On sale' %}{% endif %}
              {% when 'sold-out' %}
                {% assign product_status = 'Sold out' %}
              {% when 'coming-soon' %}
                {% assign product_status = 'Coming soon' %}
            {% endcase %}
            {% capture image_class %}
              {% if product.image.height > product.image.width %}
                image-tall
                {% if theme.grid_image_style == 'crop-to-square' %}
                  {% assign product_image_constrain_height = '' %}
                  {% assign product_image_constrain_height_large = '' %}
                  {% assign thumb_constrain_height = '' %}
                {% endif %}
              {% elsif product.image.height < product.image.width %}
                image-wide
                {% if theme.grid_image_style == 'crop-to-square' %}
                  {% assign product_image_constrain_width = '' %}
                  {% assign product_image_constrain_width_large = '' %}
                  {% assign thumb_constrain_width = '' %}
                {% endif %}
              {% else %}
                image-square
              {% endif %}
            {% endcapture %}
            <div class="product-list-thumb {{ theme.grid_image_style }} {{ theme.show_overlay }}">
              <a class="product-list-link" href="{{ product.url }}" title="View {{ product.name | escape }}">
                <div class="product-list-thumb-container">
                  <figure class="product-list-image-container">
                    <div class="image-wrapper">
                      <img alt="" class="lazy product-list-image {{ image_class }}" src="{{ product.image | product_image_url | constrain: thumb_constrain_width,thumb_constrain_height }}" data-src="{{ product.image | product_image_url | constrain: product_image_constrain_width, product_image_constrain_height }}" data-srcset="{{ product.image | product_image_url | constrain: product_image_constrain_width_large, product_image_constrain_height_large }} 2x, {{ product.image | product_image_url | constrain: product_image_constrain_width, product_image_constrain_height }} 1x">
                    </div>
                  </figure>
                </div>
                <div class="product-list-thumb-info">
                  <div class="product-list-item-background"></div>
                  <div class="product-list-thumb-info-headers">
                    <div class="product-list-thumb-name">{{ product.name }}</div>
                    <div class="product-list-thumb-price">
                      {% if product.variable_pricing %}
                        {{ product.min_price | money: theme.money_format }} - {{ product.max_price | money: theme.money_format }}
                      {% else %}
                        {{ product.default_price | money: theme.money_format }}
                      {% endif %}
                      {% if product_status != blank %}
                        <div class="product-list-thumb-status">{{ product_status }}</div>
                      {% endif %}
                    </div>
                  </div>
                </div>
              </a>
            </div>
          {% endfor %}
        </div>
      </div>
    {% else %}
      <div class="empty-products centered-message">No products found.</div>
    {% endif %}
  {% endget %}
{% endif %}


0
投票

上述解决方案对我不起作用。它将每个链接添加到每个图像。

不是图像 1 上的链接 1,图像 2 上的链接 2,而是图像 1 上的链接 1,图像 1 上的链接 2,图像 1 上的链接 3,图像 2 上的链接 1,图像 2 上的链接 2,等等。 ..

© www.soinside.com 2019 - 2024. All rights reserved.