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

Popular posts from this blog

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

php - Using str_replace to translate a MySQL Table in html -

asp.net mvc - Cannot display error message on Editor or EditorFor -