生成插件上的缩略图图像。

huangapple go评论49阅读模式
英文:

Generate thumbnail image on plugin

问题

如何为自定义插件中的此部分生成缩略图图像?

{% for element in category.img.elements %}
   {% if element.media.url %}
      <img src="{{ element.media.url }}" class="product-image is-standard">
   {% endif %} 
{% endfor %}

在这段代码中,它只显示主图像,我想为该图像生成缩略图。

英文:

how can I generate the thumbnail image for this section on the custom plugin?

{% for element in category.img.elements %}
   {% if element.media.url %}
      &lt;img src=&quot;{{ element.media.url }}&quot; class=&quot;product-image is-standard&quot;&gt;
   {% endif %} 
{% endfor %}

on this code it's only showing main image, I want to generate the thumbnail for that image

答案1

得分: 1

使用sw_thumbnails助手

{% for element in category.img.elements %}
    {% sw_thumbnails 'category-img-thumbnails' with {
        media: element.media,
        sizes: {
            'default': '200px'
        },
        attributes: {
            'class': 'some-class',
            'alt': 'alternative',
            'title': 'title'
        }
    } %}
{% endfor %}
英文:

Use the sw_thumbnails helper.

{% for element in category.img.elements %}
    {% sw_thumbnails &#39;category-img-thumbnails&#39; with {
        media: element.media,
        sizes: {
            &#39;default&#39;: &#39;200px&#39;
        },
        attributes: {
            &#39;class&#39;: &#39;some-class&#39;,
            &#39;alt&#39;: &#39;alternative&#39;,
            &#39;title&#39;: &#39;title&#39;
        }
    } %}
{% endfor %}

huangapple
  • 本文由 发表于 2023年6月22日 17:53:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76530663.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定