All Projects → MatteoGabriele → Vue Progressive Image

MatteoGabriele / Vue Progressive Image

Licence: mit
Vue progressive image loading plugin

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vue Progressive Image

Next Optimized Images
🌅 next-optimized-images automatically optimizes images used in next.js projects (jpeg, png, svg, webp and gif).
Stars: ✭ 1,870 (+173.39%)
Mutual labels:  plugin, image
Summernote Image Attributes
Summernote plugin to edit image attributes
Stars: ✭ 78 (-88.6%)
Mutual labels:  plugin, image
Mediumlightbox
Nice and elegant way to add zooming functionality for images, inspired by medium.com
Stars: ✭ 671 (-1.9%)
Mutual labels:  plugin, image
Flutter photo
Pick image/video from album by flutter. Support ios and android. UI by flutter, no native.
Stars: ✭ 285 (-58.33%)
Mutual labels:  plugin, image
Flutter image editor
Flutter plugin, support android/ios.Support crop, flip, rotate, color martix, mix image, add text. merge multi images.
Stars: ✭ 181 (-73.54%)
Mutual labels:  plugin, image
Uppload
📁 JavaScript image uploader and editor, no backend required
Stars: ✭ 1,673 (+144.59%)
Mutual labels:  plugin, image
Nuxt Optimized Images
🌅🚀 Automatically optimizes images used in Nuxt.js projects (JPEG, PNG, SVG, WebP and GIF).
Stars: ✭ 717 (+4.82%)
Mutual labels:  plugin, image
Jqueryrotate
jQueryRotate - plugin to rotate images by any angle cross-browse with animation support
Stars: ✭ 157 (-77.05%)
Mutual labels:  plugin, image
Photofilters
photofilters library for flutter
Stars: ✭ 229 (-66.52%)
Mutual labels:  plugin, image
Flutter photo manager
Provide flutter with the ability to manage photos.
Stars: ✭ 294 (-57.02%)
Mutual labels:  plugin, image
Sonar Cxx
SonarQube C++ plugin (Community): This plugin adds C++ support to SonarQube with the focus on integration of existing C++ tools.
Stars: ✭ 649 (-5.12%)
Mutual labels:  plugin
Vim Vide
Lightest vimrc, while strong enough. 最轻的vim配置,却足够强!
Stars: ✭ 649 (-5.12%)
Mutual labels:  plugin
Vue Stripe
Stripe Checkout & Elements for Vue.js
Stars: ✭ 669 (-2.19%)
Mutual labels:  plugin
Laravel Imageup
Auto Image & file upload, resize and crop for Laravel eloquent model using Intervention image
Stars: ✭ 646 (-5.56%)
Mutual labels:  image
Slinky
A light-weight, responsive, mobile-like navigation menu plugin
Stars: ✭ 649 (-5.12%)
Mutual labels:  plugin
Tandem
Typing in Tandem. Decentralized, cross-editor, collaborative text-editing!
Stars: ✭ 678 (-0.88%)
Mutual labels:  plugin
Vscode Plugin Demo
VSCode插件开发全攻略配套demo
Stars: ✭ 647 (-5.41%)
Mutual labels:  plugin
Jspaint
🎨 Classic MS Paint, REVIVED + ✨Extras
Stars: ✭ 5,972 (+773.1%)
Mutual labels:  image
Sota Medseg
SOTA medical image segmentation methods based on various challenges
Stars: ✭ 677 (-1.02%)
Mutual labels:  image
React Native Fast Image
🚩 FastImage, performant React Native image component.
Stars: ✭ 6,500 (+850.29%)
Mutual labels:  image

vue-progressive-image

Vue progressive image loading plugin

alt tag

Installation

$ npm install vue-progressive-image

Usage

import Vue from 'vue'
import VueProgressiveImage from 'vue-progressive-image'

Vue.use(VueProgressiveImage)

Progressive image

Instead of using the normal img tag to load images

<img src="https://unsplash.it/1920/1080?image=10" />

use the progressive-img component already globally available after the plugin installation

<progressive-img src="https://unsplash.it/1920/1080?image=10" />

Progressive background

It is also possible to apply progressive images as backgrounds and it will have the same props as the progressive-img component

<progressive-background src="https://unsplash.it/1920/1080?image=10" />

Placeholders

To be able to immediately show some feedback to the user, it is possible to pass a placeholder image, which could be also 1% the size of the main image: it will be blurred so you can go crazy with optimizations here.

in this example I actually use the same image, but you have the idea here

<progressive-img
  src="https://unsplash.it/1920/1080?image=10"
  placeholder="https://unsplash.it/1920/1080?image=10"
/>

The slot (progressive-background only)

The progressive-background has a "content" slot, which can hold content that needs to be rendered over the background image and also can hold a preloader. This slot has one property called "visible" that tells you when, for example, a preloader needs to be visible or not.

<progressive-background src="https://unsplash.it/1920/1080?image=10">
  <div slot="content" slot-scope="{ visible }">
    <p>I am some content to display over the image</p>
    <div v-show="visible">I am the preloader</div>
  </div>
</progressive-background>

Blur

It is possible to adjust the level of blur applied to the placeholder image

<progressive-img
  src="https://unsplash.it/1920/1080?image=10"
  placeholder="https://unsplash.it/1920/1080?image=10"
  :blur="30"
/>

Ratio

It is possible to remove the padding that adds the aspect ratio to the container.

<progressive-img
  src="https://unsplash.it/1920/1080?image=10"
  no-ratio
/>

It is also possible to manually specify the image aspact ratio when you know it. It allows the placeholder to be displayed in the correct aspect ratio. The ratio is calculated as height / width.

<progressive-img
  src="https://unsplash.it/1920/1080?image=10"
  aspect-ratio="1.5"
/>

Image fallback

In case of a loading error of the main image, it is possible to add a fallback image which can display an error image or just another image.

<progressive-img
  src="https://this_url_should_cause_an_error"
  fallback="https://unsplash.it/1920/1080?image=10"
/>

Events

Each component emits an event whenever an image is loaded.

Because we usually load two images, a main image and a placeholder, two events are dispatched onLoad and onLoadPlaceholder

in your js file

export default {
  methods: {
    onLoad () {
      // main image is loaded
    },
    onLoadPlaceholder () {
      // placeholder image is loaded
    },
    onError (error) {
      // main image error
    },
    onErrorPlaceholder (error) {
      // placeholder image error
    }
  }
}

in the html just add the events you need to listen to

<progressive-img
  @onLoad="onLoad"
  @onLoadPlaceholder="onLoadPlaceholder"
  @onError="onError"
  @onErrorPlaceholder="onErrorPlaceholder"
  src="https://unsplash.it/1920/1080?image=10"
  placeholder="https://unsplash.it/1920/1080?image=10"
/>

Options

During the installation process it is possible to pass some default global options

Cached images

  • type: Boolean
  • default: true

Cached images are checked by default. This check kills the animation if the image was already loaded once. If you would like to show the animation every time, even when is not needed, you can simply use the plugin options like so:

Vue.use(VueProgressiveImage, {
  cache: false
})

placeholder

  • type: String
  • required: false
Vue.use(VueProgressiveImage, {
  placeholder: 'https://unsplash.it/1920/1080?image=20'
})

blur

  • type: Number
  • required: false
  • default: 5
Vue.use(VueProgressiveImage, {
  blur: 30
})

delay

  • type: Number
  • default: 0

This options is for debug only. It lets you have an easy look at the placeholder before the main image is fully loaded.

Vue.use(VueProgressiveImage, {
  delay: 2000 // 2 seconds before the image is displayed
})

Global options like placeholder and blur will be applied only to components that don't specify their own options

Examples

Check out the example folder in the root of the repository for a small vue page with some examples on how to use the plugin. If you want to add some new example, just make a PR and I will add them :)

Issues and features requests

Please drop an issue, if you find something that doesn't work, or a feature request at https://github.com/MatteoGabriele/vue-progressive-image/issues

Follow me on twitter @matteo_gabriele

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].