Vue.js image input component

vue-picture-input

Use this Vue component to place an image input, to preview your images, with the ability to drag & drop directly and change it using a button.

Example

Installation

npm

npm install --save vue-picture-input

Usage

App.vue

<template>
<div id="app">
        <picture-input @change="onChange()" width="500" height="500" margin="16" accept="image/jpeg,image/png">
        </picture-input>
</template>

  <script>
  import PictureInput from 'vue-picture-input'

  export default {
    name: 'app',
    components: {
      PictureInput
    },
    methods: {
      onChange () {
        console.log("Picture changed!")
      }
    }
  }
  </script>

Props

  • width, height: (pixels, optional) the width and the height of the preview container. The picture will be resized and centered to cover this area. If not specified, the preview container will expand to full width, 1:1 square ratio.
  • margin: (pixels, optional) the margin around the preview container.
  • accept: (media type, optional) the accepted image type(s) (e.g. image/jpeg, image/gif, etc.) Default value: image/*.
  • id, name: (string, optional) the id and name attributes of the HTML input element.

vue-picture-input is on GitHub.