Minimalist jQuery Broken Image Fallback Plugin - brokenImage.js

File Size: 46.9 KB
Views Total: 679
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Minimalist jQuery Broken Image Fallback Plugin - brokenImage.js

Just another minimalist jQuery broken image fallback plugin that handles errors in image loading and displays an alternate image if your image fails to load.

How to use it:

1. Load the JavaScript file jquery.brokenimage.js after jQuery library and we're ready to go.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="jquery.brokenimage.js"></script>

2. Add a fallback image to the regular img tag using data-fallback attribute as follow:

<img src="1.jpg" data-fallback="fallback.jpg">

3. Call the function on the img and the plugin will do the rest.

$('img').qImageFallback();

This awesome jQuery plugin is developed by qaribhaider. For more Advanced Usages, please check the demo page or visit the official website.