I’ve been working on a website lately that’s been very heavily adding media into posts throughout their blog. We decided to move all of the new media over to Amazon’s S3 service, but they are also looking forward and know they’re going to be moving from their current system. That’s just a little bit of explanation about why I started using this little snippet, but the point is – I had to account for media that may or may not exists on Amazon’s servers. Basically, this is a quick check – without loading the entire file – just to see if the remote file exists or not, so you know whether or not you’re fine to link to that file.
Note: This will not work on an empty file.