django-imagekit icon indicating copy to clipboard operation
django-imagekit copied to clipboard

Option to suppress exceptions with templatetags

Open anentropic opened this issue 10 years ago • 2 comments

I have code like this in the template:

{% thumbnail '588x344' idea.image as thumb %}
<img src="{{ thumb.url }}" alt="{{ idea.title }}" image-ratio />

This will cause a 500 error if the source image is missing. This commonly happens during development when the database and media dir get out of sync.

IMHO there should be a way for this to easily return a 404, converting it from an error which completely breaks the page into a more appropriate 'broken image' icon from the browser.

anentropic avatar Jul 23 '14 17:07 anentropic

hmm, well it's hard to do that without swallowing all the debugging info

being able to specify a default fallback image for missing src would be handy though

anentropic avatar Jul 23 '14 17:07 anentropic

this was the simplest fix I could find - a flag on the exception class that allow Django template engine to suppress the exception

it means {{ thumb.url }} goes through as empty string, but at least I can render my page and see which image was even missing

anentropic avatar Jul 23 '14 18:07 anentropic