我需要一些幫助才能在Shopify中創建產品滑塊,以便您添加圖像和視頻。目前滑塊工作正常,但我遇到了將產品視頻添加到滑塊的問題。Shopify網站上的產品滑塊中的圖像和視頻
從我已閱讀的內容中,您可以使用alt標記添加將嵌入圖像並顯示視頻的YouTube嵌入代碼。我可以得到這個工作的第一個圖像,但它有租賃打破滑塊的其餘部分。我相信我可能需要更改默認滑塊並使用另一種替代方法。
這裏是我迄今爲止
$('#FeaturedImageZoom-product-template .product-featured-img').each (function() {
var videoid = $(this).attr("alt");
console.log(videoid);
if ($('.product-featured-img').attr("alt") == videoid) {
$(this).replaceWith('<iframe width="500px" height="500px" src="'+videoid+'?autoplay=1&showinfo=0&controls=0&modestbranding=1&rel=0" frameborder="0" allowfullscreen></iframe>');
}
});
這裏是液體的代碼去與那:
<div class="grid product-single">
<div class="grid__item product-single__photos {{ product_image_width }}{% if section.settings.image_size == 'full' %} product-single__photos--full{% endif %}">
{%- assign featured_img_src = current_variant.featured_image.src | default: product.featured_image.src -%}
{%- assign featured_img_alt = current_variant.featured_image.alt | default: product.featured_image.alt -%}
<div id="FeaturedImageZoom-{{ section.id }}" class="product-single__photo{% if product.images.size > 1 %} product-single__photo--has-thumbnails{% endif %}" {% if enable_zoom %}data-zoom="{{ featured_img_src | img_url: product_image_zoom_size, scale: product_image_scale }}"{% endif %}>
<img src="{{ featured_img_src | img_url: product_image_size, scale: product_image_scale }}" alt="{{ featured_img_alt }}" id="FeaturedImage-{{ section.id }}" class="product-featured-img{% if enable_zoom %} js-zoom-enabled{% endif %}">
</div>
{% if product.images.size > 1 %}
{% if product.images.size > 3 %}
{%- assign enable_thumbnail_slides = true -%}
{% endif %}
<div class="thumbnails-wrapper{% if enable_thumbnail_slides == true %} thumbnails-slider--active{% endif %}">
{% if enable_thumbnail_slides == true %}
<button type="button" class="btn btn--link medium-up--hide thumbnails-slider__btn thumbnails-slider__prev thumbnails-slider__prev--{{ section.id }}">
{% include 'icon-chevron-left' %}
<span class="icon__fallback-text">{{ 'sections.slideshow.previous_slide' | t }}</span>
</button>
{% endif %}
<ul class="grid grid--uniform product-single__thumbnails product-single__thumbnails-{{ section.id }}">
{% for image in product.images %}
<li class="grid__item {{ product_thumbnail_width }} product-single__thumbnails-item">
<a
href="{{ image.src | img_url: product_image_size, scale: product_image_scale }}"
class="text-link product-single__thumbnail product-single__thumbnail--{{ section.id }}"
{% if enable_zoom %}data-zoom="{{ image.src | img_url: product_image_zoom_size, scale: product_image_scale }}"{% endif %}>
<img class="product-single__thumbnail-image" src="{{ image.src | img_url: product_thumb_size, scale: product_image_scale }}" alt="{{ image.alt | escape }}">
</a>
</li>
{% endfor %}
</ul>
{% if enable_thumbnail_slides == true %}
<button type="button" class="btn btn--link medium-up--hide thumbnails-slider__btn thumbnails-slider__next thumbnails-slider__next--{{ section.id }}">
{% include 'icon-chevron-right' %}
<span class="icon__fallback-text">{{ 'sections.slideshow.next_slide' | t }}</span>
</button>
{% endif %}
</div>
{% endif %}
</div>
我讀了幾個帖子,其中列出與開發商類似的問題試圖添加產品視頻,但我還沒有遇到一個解決方案。
如果任何人都可以在這裏幫助,將不勝感激。
謝謝
謝謝。我想我只是在想它是錯誤的。你的回答幫助我達到了我需要的解決方案。 – pedz