Our site contains several lists of YouTube videos with their thumbnails related to the films themselves. We get the thumbnail URLs from the YouTube API and the hotlink for them in place on the YouTube servers. So, our image tags look like this:
<img src="http://i.ytimg.com/vi/o6CHqSN7O-o/2.jpg" alt="" width="133" height="78" />
The problem is that sometimes the video is deleted - as well as the thumbnail. We do not know when this can happen, and our thumbnails simply turn into broken images. How can we handle this?
There are a number of solutions:
Download the thumbnails and save them locally - the film will not work if it is deleted, of course, but this is normal, it will explain that it was deleted, and we avoid the broken image.
Check the API periodically to see if the thumbnail has changed, if it no longer exists, replace our own snapshot with the movie removed. It's pretty hard to call an API!
Use javascript to replace broken images (don't like it a lot)
Our ideal solution would be to point img src to a location on YouTube that displays a friendly “remote” image when the movie is released. However, it does not seem to exist.
Has anyone else dealt with this? Thank!
source
share