Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top