This time I will share jQuery Plugin and tutorial about Minimalist jQuery Broken Image Fallback Plugin – brokenImage.js, hope it will help you in programming stack.
File Size: | 46.9 KB |
---|---|
Views Total: | 597 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
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.
1 |
< script src = "//code.jquery.com/jquery.min.js" ></ script > |
2 |
< script src = "jquery.brokenimage.js" ></ script > |
2. Add a fallback image to the regular img
tag using data-fallback
attribute as follow:
1 |
< img src = "1.jpg" data-fallback = "fallback.jpg" > |
3. Call the function on the img
and the plugin will do the rest.
1 |
$( 'img' ).qImageFallback(); |
This awesome jQuery plugin is developed by qaribhaider. For more Advanced Usages, please check the demo page or visit the official website.
source : jqueryscript.net