You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Wagtail中图片显示放大异常问题求助

Wagtail图片始终呈现放大状态,fill+crop参数设置无效求助

我尝试用Wagtail展示图片,但图片总是处于放大状态。已经参照最新官方文档,使用fill搭配crop参数设置,试过各种尺寸组合(带或不带c参数),但都没有效果。

示例图片原始尺寸为269x540:
示例图片

实际显示效果:
实际显示效果

相关组件模板代码如下:

{% load wagtailimages_tags %}

/// 问题核心部分,我尝试了各种尺寸,带或不带c参数
{% image  value.illustration fill-300x600-c100  as cover %}

<div class="grid grid-cols-1 sm:grid-cols-2" {% if value.bg_color %}style='background:{{ value.bg_color }} !important;'{% endif %}>

    <div class="text-center py-20 px-4 inline-block bg-center 
        {% if value.position != '0' %}
            sm:hidden
        {% endif %}
        "
        style='background-image:url("{{ cover.url }}");'>
    </div>

    <div class='text-center py-20 px-6 sm:px-12 md:px-12 lg:px-18 xl=px-24'>
        {% if value.over_title %}
            <h2 class="text-base font-semibold text-redfuf-900 tracking-wide uppercase" >
                {{ value.over_title }}
            </h2>
        {% endif %}
        <p class="mt-1 text-xl font-extrabold text-gray-900 pb-6 sm:text-xl sm:tracking-tight lg:text-2xl"
        {% if value.text_color %}style='color:{{ value.text_color }} !important;'{% endif %}>
            {{ value.title }}
        </p>
        {% if value.caption %}
        <div class="max-w-7xl mx-auto pb-6 px-4 text-justify sm:pb-12 px-0 lg:px-8">
            {{ value.caption }}
        </div>
        {% endif %}
        {% if value.CAT_link or value.snippet_cta %}
            <a {% if value.CAT_link %}href='{{ value.CAT_link }}'{% elif value.snippet_cta %}href='{{ value.snippet_cta }}'{% endif %} {% if value.CAT_blank %}target='_blank'{% endif %}>
                <button type="button" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-bluefuf-600 hover:bg-bluefuf-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-bluefuf-900">
                    {{ value.CAT_title }}
                </button>
            </a>
        {% endif %}
    </div>

    <div class="text-center py-20 px-4 hidden  bg-cover
        {% if value.position == '1' %}
            sm:inline-block
        {% endif %}
        "
        style='background-image:url("{{ cover.url }}");'>
    </div>

</div>

恳请各位提供技术帮助,谢谢!


内容的提问来源于stack exchange,提问作者mdc123

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 03:31:36