One of the neat little things I’ve learned on the big project I am on is how to show a default image if the one you need isn’t found.
To give a bit of a background, my last two jobs have been on catalog like websites. Where you have thousands (on the bigger site… hundreds of thousands) of items in the catalog. Each with several size variations of the image. At my prior employer I had a pretty complex algorithm to determine if an image was available. At the most basis level, querying the the hard drive to see if the file exist. What I am using now is handled on the client side, and I tend to like the performance a bit more.
In a standard image tag, you have the following:
<img alt=”” src=”someimage.jpg” />
Adding a simple onerror tag to it, gives you a default image if the one you expect to be there doesn’t exist:
<img alt=”” src=”someimage.jpg” onerror=”this.onerror=null;this.src=’default.jpg’;” />
Pretty nice little trick, surprised I had never heard of it.