npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@zakerxa/vue-multiple-image-upload

v1.0.10

Published

This is Vue Multiple Image Upload with Preview, Resize, Remove, Add More, Drag & Drop features are included.

Downloads

161

Readme

Vue Multiple Image Upload

Welcome Back

Hello Everyone,My name is Zin Min Htet and here is my Facebook account.

Now, I will show you how to Upload Multiple Image using Vue-Component.

There is an image Preview, Resize, Remove, Add More, Drag & Drop features are included.

You can also limit the maximun number of file upload, the Image size , the Image type.

I add new feature alert Box, Resize Image, Preview also can be resize in version 1.0.8;

Here is Live Demo

Watch Now Live Demo.

Installation

npm i @zakerxa/vue-multiple-image-upload

Setup

1 - Import the vue component locally in the script Tag

<script>
 import { VueMultiImageUpload } from '@zakerxa/vue-multiple-image-upload';

  export default {
    components:{
      VueMultiImageUpload
    }
  }
</script>

OR Global registration in your main.js

 import { VueMultiImageUpload } from '@zakerxa/vue-multiple-image-upload';
 const app = createApp(App);
 app.component("vue-multi-image-upload", VueMultiImageUpload);

2 - In your Vue Template

<template>
    <vue-multi-image-upload @data-image="images" :max="4" :data-reset="component"/>
</template>

⇃⇃⇃⇃⇂⇂⇂⇂

<script>
export default {
    data(){
      return {
        component : {}
      },
    },
    methods:{
        images(e){
          e.map(res=>console.log(res))
        },
        clear(){
            this.component.clear = true;
        }
    }
}

</script>

Props & Type

Explanation of usage

1.Images methods can listen child input data from parent the component.

  @data-image="images"
  images(e){
   e.map(res=>console.log(res))
  }

2.We can Resize the images by adding resize props

:resize={ h:500, w:500 ,keepRatio:true}
h => max-height of the image
w => max-width of the image

keepRatio true can resize your image without losing distortion
keepRatio false can resize your image exactly width & height

Default is False

3.We can limit the number of image to upload maximun

:max="limitNumber"

4.We can also limit the images size & type.

:image-size="imageSize" :accept="imageType"

this.imageSize = 2e6; // 2MB
ImageSize only allow 2MB else We will show alert msg to user.

this.imageType = ['image/jpeg', 'image/png', 'image/gif'];
imageType should be inside an array

5.And, There is one options.Options can change the message inputBox.

:options="options"
this.options.max = "Max";
this.options.ready = "Ready";
this.options.select = "Choosed";

6.If you want to reset child component data,You can use :data-reset props to passing Object

:data-reset="components"
this.component.clear = true;

Final State

That's all what you need

<template>
   <vue-multi-image-upload 
     @data-image="images" 
     :max="4" 
     :image-size="4e6"  
     :alert-timeout="3e3" 
     :accept="imageType"
     :preview="{ h:100,w:100 }"
     :resize="{ h:500,w:500, keepRatio:true}" 
     :data-reset="component" 
     :options="options"  
    />
   <button @click="clear()">Clear</button>
</template>

<script>

import { VueMultiImageUpload } from '@zakerxa/vue-multiple-image-upload';

export default {
    data(){
        return {
          component : {},
          inputImages : [],
          imageType : ['image/jpeg', 'image/png', 'image/gif']
        }
    },
    components:{
      VueMultiImageUpload
    },
    methods:{
      images(e){
        this.inputImages = e;
      },
      inputFormData(){
        // The way to append images to FormData.
        let formData = new FormData();
        this.inputImages.map(img => formData.append('images[]',img));
        return formData;
      },
      clear(){
        this.component.clear = true;
      }
    }
}
</script>