-1

显示此错误:

“图像”标签的格式应为 {% image self.photo max-320x200 [ custom-attr="value" ... ] %} 或 {% image self.photo max-320x200 as img %}

第 19 行 {% image block.value as mein_bild %}

我的模板:

{% extends "base.html" %}
{% load static wagtailcore_tags wagtailimages_tags %}

{% block content %}

  <div class="notiert">
    <header>
      <h1>{{ page.title }}</h1>
    </header>
   <div class="body">
     {{ page.kurzfassung|richtext }}
     <p>{{ page.first_published_at }}</p>
     {% for block in self.notiert_feld %}
        {% if block.block_type == 'image' %}
           <p>in if image {{ block.value }}</p> 
           {% image block.value as mein_bild %}
           <img {{ mein_bild }} width=530 > 
        {% else %}
          {{ block.value }}
        {% endif %}
    {% endfor %}
    </div>    
  </div>

{% 端块 %}

第 18 行我用于调试。如果我删除第 19 行和第 20 行,则会显示图像的名称。

4

2 回答 2

1

我以为我尝试了这个变体并得到了一个错误。但现在它起作用了。

{% extends "base.html" %}
{% load static wagtailcore_tags wagtailimages_tags %}



{% block content %}


  <div class="notiert">
    <header>
      <h1>{{ page.title }}</h1>
    </header>
      <div class="body">
         {{ page.kurzfassung|richtext }}
         <p>{{ page.first_published_at }}</p>
         {% for block in self.notiert_feld %}
            {% if block.block_type == 'image' %}
                {% image block.value width-530 %}
            {% else %}
                {{ block.value }}
            {% endif %}
         {% endfor %}
    </div>    
  </div>




{% endblock %}

感谢您的回答!

于 2018-10-01T08:16:44.180 回答
0

https://docs.wagtail.io/en/stable/topics/images.html中所述,您需要包含一个调整大小规则来指示图像应呈现的大小。如果您不希望调整图像大小,请使用original(但请记住,如果编辑器上传过大的图像,它可能会破坏您的页面布局和/或浪费带宽):

{% image block.value original as mein_bild %}
于 2018-10-01T07:05:29.210 回答