Code Monkey home page Code Monkey logo

angular-img-fallback's Introduction

Angular Image Fallback

Angular directives that handles image loading, it has fallback-src to handle errors in image loading and loading-src for placeholder while the image is being loaded.

Bower Download

bower install angular-img-fallback

Installation

  1. Download and import the plugin script.
    <script src="lib/angular-img-fallback/angular.dcb-img-fallback.min.js"></script>
  2. Add dcbImgFallback to your angular app module dependencies list.
    angular.module('myAngularApp', ['dcbImgFallback']);
  3. Add the fallback-src attribute to your img
    <img ng-src="{{'path/to/img.jpg'}}" fallback-src />

Usage

Just add the fallback-src and the loading-src attributes to your <img /> tags
<img ng-src="{{'path/to/img.jpg'}}" fallback-src loading-src />
Make sure you use ng-src as your image src attribute.

Advanced options

  • Simple usage, will replace to a default missing image placeholder
    <img ng-src="{{'path/to/img.jpg'}}" fallback-src />

  • Custom fallback, will replace to your own custom missing image
    <img ng-src="{{'path/to/img.jpg'}}" fallback-src="{{'path/to/fallback.jpg'}}" />

  • Loading placeholder, show a loading placeholder until image loads
    <img ng-src="{{'path/to/img.jpg'}}" loading-src />

  • Custom Loading placeholder, show a custom image loading placeholder until image loads
    <img ng-src="{{'path/to/img.jpg'}}" loading-src="{{'path/to/loading.jpg'}}" />

  • Or both! loading placeholder and a fallback source can work together
    <img ng-src="{{'path/to/img.jpg'}}" loading-src fallback-src />

Icons license

Icons are provided from http://icomoon.io/ under the GNU General Public License v3.0
http://www.gnu.org/licenses/gpl.html

Contributing

To produce a distributable build, install Uglify JS by running npm install uglify-js -g and uglifyjs angular.dcb-img-fallback.js -c -m -o angular.dcb-img-fallback.min.js

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.