1.0.2 • Published 3 years ago

v-img-error v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

NPM Version NPM Dependencies NPM Downloads MIT License

Git Stars Git fork

A simple Vue directive to catch img errors & broken links and replace them with default or custom fallback image. NO dependencies!

If you like this project, please give it a star & consider following the author. :)

Installation

npm install v-img-error

Install globally

main.js

import Vue from 'vue';
import vImgError from 'v-img-error';

Vue.use(vImgError)

Install locally

component.vue

import { vImgError as imgError } from  "v-img-error";

export default {
   directives: {
      imgError
   }
}

Basic Usage

<template>
    <img src="myImg.png" v-img-error>
    <img src="anotherImg.svg" v-img-error>
</template>

Advanced Usage

With your custom fallback Img:

<template>
    <img src="myImg.png" v-img-error="path/to/image">
    <img src="anotherImg.svg" v-img-error="path/to/svg">
</template>

Authors

Maor Barel

License


MIT © Maor Barel