Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

25 lines (18 sloc) 0.598 kB

jquery-imagefallback

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.

Usage

There are two ways to use it.

  1. Specify a fallback image URL
$('img.photo').fallback('http://google.com/fallback.jpg');
  1. Specify a callback function:
    $('.photo-container > img').fallback(function () {
        $('.photo-container').hide();
    }).attr('src', 'http://my.photosite.com/image1.jpg');
Jump to Line
Something went wrong with that request. Please try again.