Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VueJs Multiple Instances of Uppload #861

Open
buzzclue opened this issue Jul 21, 2022 · 2 comments
Open

VueJs Multiple Instances of Uppload #861

buzzclue opened this issue Jul 21, 2022 · 2 comments

Comments

@buzzclue
Copy link
Contributor

buzzclue commented Jul 21, 2022

Describe the bug
Using Uppload v2.x with VueJs 2.7.x and my vue component looks like this:

<template>
    <div @click="open">
        <slot />
    </div>
</template>

<script>
    import { Uppload, en } from "uppload";
    import { Preview, Crop, Brightness, Grayscale, Sepia, Rotate, Blur, Flip } from "uppload";
    import { Screenshot, Local, URL, Unsplash, GIPHY, Pexels, Pixabay } from "uppload";

    export default {
        name: "MediaSelect",
        props: {
            mimes: {
                type: Array,
                default: function () {
                    return [
                        "image/gif",
                        "image/jpeg",
                        "image/jpg",
                        "image/png",
                    ]
                }
            },
            multiple: {
                type: Boolean,
                default: false
            },
            show: {
                type: Boolean,
                default: false
            },
            maxFileSize: {
                type: Number,
                default: function () {
                    return this.$variables.max_size ? this.$variables.max_size : 25000
                }
            },
            uploader: Function
        },
        created() {
            if (!this.uppload) {
                this.uppload = new Uppload({
                    lang: en,
                    uploader: this.uploader,
                    showHelp: true,
                    multiple: this.multiple,
                    maxFileSize: this.maxFileSize,
                    defaultService: 'local',
                    transitionDuration: 1,
                    compression: 0.8,
                    compressionFromMimes: ["image/jpeg", "image/png", "image/webp"],
                    compressionToMime: "image/webp"
                });

                let services = [];
                services.push(new Crop())
                services.push(new Flip())
                services.push(new Brightness())
                services.push(new Grayscale())
                services.push(new Sepia())
                services.push(new Rotate())
                services.push(new Blur())
                services.push(new Preview())

                services.push(new Local({
                    mimeTypes: this.mimes
                }))
                services.push(new URL())
                services.push(new Screenshot())
                services.push(
                    new GIPHY(this.$variables.giphy_access_key)
                )

                this.uppload.use(services);
                this.uppload.on("upload", url => this.$emit("input", url))
                this.uppload.on("close", () => this.$emit("close"))
                this.uppload.on("open", () => this.$emit("open"))
            }
        },
        methods: {
            open() {
                this.uppload.open();
            },  
        },
    }
</script>

To Reproduce
Steps to reproduce the behavior:
When multiple instances of this component are created then the services navigation work on the first one initialized but won't work others.

Expected behavior
Navigation should work on every instance.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Firefox, Chrome
  • Version Latest versions
@buzzclue
Copy link
Contributor Author

buzzclue commented Jul 22, 2022

PR #863 will resolve the issue.

@AnandChowdhary
Copy link
Contributor

Amazing, thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants