设置Django / Wagtail CMS网站。尝试为图像创建模板,该模板将大小作为变量,并包括以下模板:
{% include "patterns/molecules/media/image.html" with media=page.featured_image caption=page.image_caption imgclass="extra-wide" sizing="fill-854x480" %}
然后在模板中,我使用以下代码:
{% with sizing as size %}
{% if size %}
{% image media size as img %}
{% else %}
{% image media fill-1280x720 as img %}
{% endif %}
{% endwith %}
但是,它最终出现异常:
InvalidFilterSpecError at /slug/
Unrecognised operation: size
Request Method: GET
Request URL: http://localhost:8000/slug/
Django Version: 2.1.7
Exception Type: InvalidFilterSpecError