易于保存到S3桶的缩略图

时间:2019-12-28 18:24:34

标签: django amazon-s3 easy-thumbnails

我正在尝试使用S3存储桶在Django应用中使用易用的缩略图。

我正尝试在轮播中显示您的图像,如下所示:

{% for image in organisation.photos %}
    <div class="carousel-item{% if forloop.first %} active{% endif %}">
        <img class="d-block w-100" src="{% thumbnail image.file 'carousel_image' subject_location=image.file.subject_location %}" alt="{{ image.name }}">
    </div>
{% endfor %}

如果存在该图像,则可以很好地下载该图像,但如果不存在,则该图像会显示404 Not Found消息,而我希望它们会生成。

这里是否缺少我想要的东西,或者我需要添加具有S3 Bucket权限的东西,以便于轻松创建图像?

1 个答案:

答案 0 :(得分:0)

这有效吗?

 {% for image in organisation.photos %}
     {% if image %}
        <div class="carousel-item{% if forloop.first %} active{% endif %}">
            <img class="d-block w-100" src="{% thumbnail image.file 'carousel_image' subject_location=image.file.subject_location %}" alt="{{ image.name }}">
        </div>
    {% endif %
    {% endfor %}