Find file
Fetching contributors…
Cannot retrieve contributors at this time
25 lines (18 sloc) 598 Bytes


Encapsulate fallback behavior when images fail to load. Works with Zepto.js as well. :)

Call $('.foo').fallback on an image selector to fallback to another image if the main image fails to load.


There are two ways to use it.

  1. Specify a fallback image URL
  1. Specify a callback function:
    $('.photo-container > img').fallback(function () {
    }).attr('src', '');