【问题标题】:Sorl-thumbnail--> Image height is not equals to the given heightSorl-thumbnail--> 图像高度不等于给定高度
【发布时间】:2020-08-29 17:04:23
【问题描述】:

当我在前端看到图像宽度为 430 但高度不等于给定高度(250)时执行以下代码后,它是 100

{% 加载缩略图 %} {% thumbnail recipe.image "430x250" as thumb %} {% endthumbnail %}

【问题讨论】:

  • 当您检查图像时,内在图像大小如何,您可以使用 CSS 规则来调整图像大小

标签: django


【解决方案1】:

您可以使用以下策略来渲染具有给定高度和宽度的图像。 document中提到了示例的用法。

{% load thumbnail %}
{% thumbnail recipe.image "430x250" crop="center" as img %}
    <img src="{{ img.url }}" width={% firstof img.width "430" %} height={% firstof img.height "250" %} alt=""/>
{% endthumbnail %}

【讨论】:

    猜你喜欢
    • 2011-12-18
    • 2018-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-10
    • 1970-01-01
    • 2010-11-08
    • 1970-01-01
    相关资源
    最近更新 更多