Being able to generate a thumbnail for an image file isn't guaranteed. Occasionally it fails, more frequently for certain image formats. Or for files that were mistakenly assigned image mime types. This results in a condition where the application will try to generate and cache the thumbnail, causing a delay, on every page load.
We have a boolean database flag indicating that the thumbnails are already generated for a specific file. Let's add a "bad image, don't even try" flag as well.
(an existing admin workaround for this condition of course is to generate and cache the files with the right .thumb* extensions outside of the application; whether the actual thumbnails, when possible, or of some "broken image" icon, if it's not a valid image file. changing the mime type in the latter case is also an option)w