python - Flask and Jinja for loop skip if file contains errors -
i'm having issue trying display thumbs. problem when run jinja2 variable displays alt text, rather have skip or pass if thumb contains errors instead of displaying alt text.
here code
{% block content %} {% if games %} {% g in games if g.game_thumb %} <img src="static{{ g.game_thumb }}" class="img-rounded" alt="{{ g.game_name }}" width="150" height="150"> {%endfor%} {% endif %} {% endblock %}
i ended solving via flask route via.
from pil import image try: image.open(thumb).verify() print "image" except: print "failed" continue
Comments
Post a Comment