How Craft reacts to missing images is one of the very few places where I find Craft less than ideal.
TL:DR;
- Is there a way to make missing images not become a fatal error?
- How do you find elements that are referencing the missing image?
Long version:
There are a number of ways images can be missing, for example:
- Our workflow involves developing locally, then putting up to staging for clients to add content. Sometimes we need to then do more local development, local and stage both share the same database... but not images.
- An image is simply corrupt, due to transfer or disk failure (it happens)
- A filesystem is reverted to a previous state but the database is not
- A live server dies and a project is restored to a new machine from SVN/GIT, but the assets are not in version control and therefore not available
- Getting hold of the images on local isn't possible temporarily because you're working on a restricted internet connection; like on a plane.
Any of these result in instances of 'blahblah.jpg could not be found' in Dev mode or Internal Server Error in production. Sometimes those images actually get lost; they just don't exist any more; but they're in the database. So...
How do you find what element is referencing these lost files? Besides manually trawling through entries, related entries, etc? Crafts error gives no useful information about that, and rebuilding asset indexes doesn't seem to make Craft aware that the image isn't available anymore.
And...
Is there an option to just ignore these types of error - it's not helpful in production to have a whole page 'internal server error' just because a single image referenced on the page is missing from the file system for whatever reason. A missing image is not a throw-the-baby-out-with-the-bathwater problem.