Vue image placeholder directive for broken images.

Overview

Vue Image Fallback

v-img-fallback

Vue image placeholder directive for broken images.

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

Usage

Install with NPM or Yarn

npm install v-img-fallback --save

yarn add v-img-fallback

Transpile for target: es5

This module is distributed as an esm module.

If you need backwards compatibility, you will need to transpile this module:

// in your vue.config.js for vue-cli-3
module.exports = {
  /* ... other config ... */
  transpileDependencies: ['v-img-fallback']
}

Install globally

import Vue from 'vue';
import VueImgFallback from 'v-img-fallback';

Vue.use(VueImgFallback, {
  loading: 'path/to/loading/image',
  error: 'path/to/error/image'
});

Install locally

<template>
  <img src="foo.png" v-img-fallback="imgFallback">
template>

<script>
import { ImgFallback } from 'v-img-fallback';

export default {
  directives: {
    ImgFallback
  },
  data: () => {
    imgFallback: {
      loading: 'path/to/loading/image',
      error: 'path/to/error/image'
    }
  }
};
script>

API

This directive can receive string or object value.

string

Path or image url. This value will be used in both loading and error state.

object

{
  loading: 'path/to/loading/image',
  error: 'path/to/error/image'
}

Sample - pass a string

<template>
  <img src="foo.png" v-img-fallback="path/to/placeholder">
template>

Sample - pass an object

<template>
  <img src="foo.png" v-img-fallback="imgFallback">
template>

<script>
  export default {
    data: () => {
      imgFallback: {
        loading: 'path/to/loading/image',
        error: 'path/to/error/image'
      }
    }
  }
script>

Update

January 25, 2018 - Added options object to Vue.use(VueImgFallback, options). Options should have loading and error properties. These values will always be overwritten by the value inside v-img-fallback directive.

Tips

loading value can be a .gif Gee. Ahy. Ef. (I will die with dignity LOL).

Made with โค๏ธ by Jofferson Ramirez Tiquez

You might also like...
An interactive vue component that displays multiple images in a row

vue image wall An interactive vue component that displays multiple images in a row. By hovering mouse over one of the images, that image will expand i

V-img is a plugin for Vue.js that allows you to show images in full-screen gallery
V-img is a plugin for Vue.js that allows you to show images in full-screen gallery

V-img is a plugin for Vue.js that allows you to show images in full-screen gallery

Webpack loader used for inline replacement of SVG images with actual content of SVG files in Vue projects.

vue-svg-inline-loader Webpack loader used for inline replacement of SVG images with actual content of SVG files in Vue projects. Loader parses only HT

Optimized Images for Nuxt
Optimized Images for Nuxt

Optimized Images for Nuxt

Collecting images and photos like a pro.
Collecting images and photos like a pro.

Scrapbook Collecting images and photos like a pro. Demo demo Why When you have a tons of photos you took while your traveling, or art images you downl

๐ŸŽจ A vue directive for the cosha library
๐ŸŽจ A vue directive for the cosha library

vue-cosha Vue cosha is a simple port of the cosha library for ease of use in Vue projects. "Colorful shadows for your images. ๐ŸŽจ " cosha lets you add

A directive supported plugin for PhotoSwipe in Vue.js components.

vue-photoswipe.js A directive supported plugin for PhotoSwipe in Vue.js components. install npm i vue-photoswipe.js -s Import photoswipe component and

Vue progressive image loader plugin like Medium
Vue progressive image loader plugin like Medium

vue-image-loader Vue progressive image loading plugin Article here : https://www.kevindesousa.me/vue-image-loader/ Installation $ npm install @kevinde

๐Ÿ™‹โ€โ™€๏ธ Image magic animation drawing effect component for Vue 2.x | ๅ›พๅƒๅŠจๆ€็ป˜ๅˆถๆ•ˆๆžœ
๐Ÿ™‹โ€โ™€๏ธ Image magic animation drawing effect component for Vue 2.x | ๅ›พๅƒๅŠจๆ€็ป˜ๅˆถๆ•ˆๆžœ

vue-image-painter English | ็ฎ€ไฝ“ไธญๆ–‡ ๐ŸŒฐ Example Demo Demo Source Code ๐Ÿš€ QuickStart Install yarn add vue-image-painter # OR npm i -S vue-image-painter Imp

Comments
  • loading override not working

    loading override not working

    Hello. Create plugin. I noticed an issue when I add a loading override image.

    This is my setting.

    Vue.use(VImgFallback, { loading: '/static/img/loading.gif', error: '/static/img/no_picture.svg' })

    The error image override does work perfectly.

    In the plugin code I get the message that loading is not declared.

    image

    Regards,

    Dennis

    Hacktoberfest 
    opened by dvergeer 3
  • ESM module not compatible with IE11

    ESM module not compatible with IE11

    Switching to ESM module is great but it breaks backward compatibility.

    It would be great to have a note in README to know how to configure webpack/vue-cli to have backward compatibility

    opened by Finrod927 1
  • Options for setting global loading/error image

    Options for setting global loading/error image

    Hey buddy! @jofftiquez

    Could you add some options to set loading or error image for every binding image.

    Such as:

     Vue.use('VImgFallback', {
        loading: 'path/to/loading.png',
        error: 'path/to/error.png'
    }
    
    enhancement good first issue 
    opened by black-black-cat 1
  • Bump esm from 3.0.84 to 3.1.0

    Bump esm from 3.0.84 to 3.1.0

    Bumps esm from 3.0.84 to 3.1.0.

    Release notes

    Sourced from esm's releases.

    3.1.0

    • Added support for export-ns-from syntax
    • Added support for options.wasm
    • Avoided โ€œ__global__ has already been declaredโ€ errors (#671)
    • Ensured esm passes all applicable test262 compliance tests
    • Ensured esm works with globally installed tink (#702)
    • Ensured esm works with lit-node (#679)
    • Ensured esm works with Node --use-strict and avoids CSP errors in Electron (#607)
    • Ensured the module.id of esm is string before using it (#681)
    • Ensured preloaded modules are reloaded when using Node -p or -e flags
    • Fixed detection of shadowed identifiers (#622)
    • Fixed dynamic import support in Electron (#692)
    • Fixed fs.realpathSync.native detection (#646)
    • Fixed options.mainFields support (#693)
    • Fixed Puppeteer support (#654)
    • Fixed re-export test case (#629)
    • Fixed regexp DoS issue (#694)
    • Raised minimum Node support for options.await to Node 10+
    • Reduced instrumentation of console and Reflect (#675)
    Commits
    • 33ee0ac Bump to v3.1.0.
    • a84a624 Update deps.
    • 9110dd2 Cleanup readme.
    • 7adc4fd Make Package exposable through require().
    • c149647 Newline nit.
    • 885afd0 Add circular entry to esm loader fake compile data.
    • c7a5a1f Update getNativeSource() for latest Node master branch.
    • 8a3d1ce Remove unneeded catch param.
    • 8e8c354 Add more entry and package cache guards to env modules.
    • b77cf1a Don't cache entry or package instances in isSideloaded().
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot ignore this [patch|minor|major] version will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language
    dependencies 
    opened by dependabot[bot] 0
Owner
Joff Tiquez
Web developer | Creator of Vue Stripe
Joff Tiquez
A Directive for setting fall back image in a vue js application if in case image is not loaded

vue-fall-back-image-directive A Directive for setting fall back image in a vue js application. Installation npm install Run npm install --save vue-fal

Arun sivan 1 Oct 15, 2019
Image comparison slider. Compare images before and after. Supports React, Vue, Angular.

Image comparison slider. Compare images before and after. Supports React, Vue, Angular.

Dmitry Snisarenko 267 Dec 18, 2022
An image finder application leveraging the Pexels api, You can also download your favorite Images too

Pexelry ?? Pexelry is an image finder web application that leverages the Pexels api to find images related to a specific search. Prerequisites Get an

Junior Developer 4 Aug 25, 2022
image-diff client: client web application to compare multiple images. online demo -

image-diff client web application to compare multiple images. you can pan, zoom and diff multiple images at the same time. currently support 8bit jpg,

Junik Jo 5 Mar 29, 2022
A Vue.js (https://github.com/vuejs/vue) plugin that offers a reusable directive to get image from Cloudinary (https://cloudinary.com)

vue-cloudinary A Vue.js plugin that offers a reusable directive to get image from cloudinary Overview This is a port of the angular-cloudinary library

Diego Pamio 25 Dec 5, 2020
A Vue component for showing loader during image loading https://john015.github.io/vue-load-image/

English | ํ•œ๊ตญ์–ด Vue-load-image Vue-load-image is 1KB(gzipped size) minimalist Vue component that display loader during image loading and display alterna

Sangwon Lee 60 Dec 7, 2022
Vue-image-loader: image loader for vue js with prevue

Vue-image-loader: image loader for vue js with prevue

null 0 Feb 1, 2020
๐ŸŒˆ A Vue image component. Simple realization of image shadow.

?? vue-image-shadow A Vue image component. Simple realization of image shadow. ?? Example Online: https://image-component.github.io/vue-image-shadow/

null 21 Aug 13, 2022
vue-image-markup will provide you to edit uploaded image easily and save it.

Markup Image with Vue.js (customizable) vue-image-markup will provide you to edit uploaded image easily and save it. Installation npm i vue-image-mark

Lionix 92 Dec 9, 2022
A vue component that allows your images to open in full size.

vue-expandable-image Allows your images to open in full size. Demo Preview Setup npm install vue-expandable-image You have two ways to setup vue-expa

Taha Shashtari 28 Oct 16, 2022