質問

when I use external images it works fine:

{% thumbnail "http://127.0.0.1:8000/media/files/logo.png" "40x40" crop="80% top" as im %}
    <img src="{{ im.url }}">
{% endthumbnail %}

But when I change first line to:

{% thumbnail "http://127.0.0.1:8000/media/{{ field.value }}" "40x40" crop="80% top" as im %}

And {{ field.value }} is string files/logo.png for sure, it doesn't work any more. Is it possible to use Django tags inside thumbnail template tag and how?

役に立ちましたか?

解決

It seems like thumbnail tag interpret {{ field.value }} literally.

How about using add filter?

{% thumbnail "http://127.0.0.1:8000/media/"|add:field.value "40x40" ... %}

Check whether field.value is a valid string.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top