Tuesday, June 30, 2015

STATIC_URL with thumbnail_url Template Tag

Hello,

I'm trying to use an image from my 'static' folder in one of my templates. I need to pass the image into the thumbnail_url filter but I can't get it to work. The image is not found. How do I specify the correct image path? (I posted this same question on stackoverflow yesterday.) Thank you!

I've tried this:

{% load thumbnail %}
<a href="{% url 'users:profile' profile.name %}">
    {% with path="{{STATIC_URL}}/images/green-icon.png" %}
    <img src="{{ path|thumbnail_url:'medium' }}" class="img-circle img-profile">
    {% endwith %}
</a>

and also:

{% load thumbnail %}  {% load staticfiles %}  <a href="{% url 'users:profile' profile.name %}">      <img src="{% static 'images/green-icon.png'|thumbnail_url:'medium' %}">  </a>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/99f1e884-eee0-4329-a689-ce72a3c69522%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment