小编ays*_*cuk的帖子

如何缩略图静态文件?

我想用sorl缩略图调整我的静态文件,但它不起作用

这是我的代码

{% if not new.photo %}

{% with path="{{STATIC_URL}}/images/empty-news.jpg" %}
{% thumbnail path "80x80" crop="center" as im %}
<a href="#" class="image"><img alt="" src="{{im.url}}" class="frame2"></a>
{% endthumbnail %}
{% endwith %}

{% else %}
{% thumbnail new.photo "80x80" crop="center" as im %}
<a href="{% url news_detail new.slug %}" class="image">
<img alt="" src="{{im.url}}" class="frame2"></a>
{% endthumbnail %}
{% endif %}
Run Code Online (Sandbox Code Playgroud)

如果我有图像它显示图像,但当我没有图像我不能使用默认图像,因为缩略图不起作用

django django-templates sorl-thumbnail

12
推荐指数
2
解决办法
5676
查看次数

标签 统计

django ×1

django-templates ×1

sorl-thumbnail ×1