Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Latest commit

 

History

History
24 lines (18 loc) · 598 Bytes

README.md

File metadata and controls

24 lines (18 loc) · 598 Bytes

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');