To use file_exists() or not?
We're having a debate over the pros and cons of using file_exists() to check whether an image exists or not, prior to deciding whether to show it or a holding image. Generally we agree that it's a good thing as it prevents image placeholders being displayed by accident, but on some pages that have a lot of images, especially ones with a lot of traffic, it hammers the server somewhat and introduces significant processing delays.
The way that it's used in this case is basically to check whether a resized, cached version of an image exists or not. If not then the image will be processed and saved as necessary. It seems to be the only way to do this particular task but we still have these performance considerations, especially on large directories on busy sites.
So I'm wondering if anyone has any thoughts and real-world solutions? Is file_exists() the best solution? is_file() instead? stream_resolve_include_path()? Just curious about what different people have chosen to do with these requirements.