【问题标题】:Can't upload video in shopifyshopify不能上传视频
【发布时间】:2020-06-24 06:59:55
【问题描述】:

我需要在产品库中添加视频。为此我正在阅读本教程https://shopify.dev/tutorials/add-theme-support-for-rich-media-3d-and-video

但是当我添加此代码时,产品图像消失了,视频也没有上传。

我在下面的产品模板和媒体中使用此代码。

   // Product-template
 {% for media in product.media %}
      {% include 'media' %}
    {% endfor %}

//In midea

    {% case media.media_type %}
      {% when 'image' %} 
            <div class="thumb">
              <a class="fancybox" rel="gallery1" href="{{ image.src | product_img_url: '1024x1024' }}" >
                <img id="product-featured-image-{{image.id}}" class="product-featured-img" src="{{ image | img_url: 'original' }}" alt="{{ image.alt | escape }}" data-zoom-image="{{ image.src | img_url: 'original' }}"/>
              </a>
            </div>
{% when 'external_video' %}
        <div class="product-single__media" style="padding-top: {{ 1 | divided_by: media.aspect_ratio | times: 100}}%;" data-media-id="{{ media.id }}">
          {{ media | external_video_tag }}
        </div>
      {% when 'video' %}
        <div class="product-single__media" data-media-id="{{ media.id }}">
          {{ media | video_tag: controls: true }}
        </div>
      {% when 'model' %}
        <div class="product-single__media" style="padding-top: 100%" data-media-id="{{ media.id }}">
          {{ media | model_viewer_tag }}
        </div>
      {% else %}
        <div class="product-single__media" style="padding-top: 100%;" data-media-id="{{ media.id }}">
          {{ media | media_tag }}
        </div>
    {% endcase %}

【问题讨论】:

标签: javascript html css shopify


【解决方案1】:

Product.media 和产品图片是不同的对象。

{% for media in product.media %}
    {% if media.media_type == 'video' %}
        {{ media | video_tag: controls: true, preload: true, image_size: "1024x" }}
    {% endif %}
{% endfor %}       
{% for image in product.images %}
        {% if forloop.first == true %}
    <figure>            
        <img src="{{ image.src | img_url: '1024x1024' }}" alt="{{ image.alt | escape }}" class="product_variant_image">
    </figure>
        {% else %}
                    <figure>            
        <img src="{{ image.src | img_url: '1024x1024' }}" alt="{{ image.alt | escape }}">
    </figure>
     {% endif %}
{% endfor %}

您需要混合使用这两个对象或将要展示的照片添加到媒体中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-01-14
    • 1970-01-01
    • 1970-01-01
    • 2015-04-19
    • 2016-01-12
    • 1970-01-01
    • 2014-04-14
    • 2014-02-24
    相关资源
    最近更新 更多