Search code examples
djangodjango-templatesdjango-media

How do i get to know if an image is rendered in a webpage? (django templates)


I ahve this code, the trouble is few of the images are having names, but corresponding to the names the files are not present, how can i know if the images are being displayed, i mean some if statement of something like that.

<img src="{{ STATIC_URL }}images/{{web.image}}" />

The above code is used to render my django image in a template. Thanks.


Solution

  • finally i have found a solution using sorl thumbnail : http://thumbnail.sorl.net/examples.html#template-examples

    {% thumbnail item.image my_size_string crop="left" as im %}
        <img src="{{ im.url }}">
    {% empty %}
        <p>No image</p>
    {% endthumbnail %}
    

    it works for me.