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

Is there an example on how to use imageUploadFunction? #334

Open
artknight opened this issue May 26, 2021 · 1 comment · May be fixed by #580
Open

Is there an example on how to use imageUploadFunction? #334

artknight opened this issue May 26, 2021 · 1 comment · May be fixed by #580
Labels

Comments

@artknight
Copy link

It would be great to see some code on how the imageUploadFunction method is supposed to be used! The docs are very slim on that!

Art

@jxxe
Copy link

jxxe commented May 24, 2022

In case anyone is finding this through Google, here's an example:

new EasyMDE({
    imageUploadFunction: (file, onSuccess, onError) => {
        const reader = new FileReader();
        reader.onload = () => onSuccess(reader.result);
        reader.onerror = () => onError(`Error loading ${file.name}`);
        reader.readAsDataURL(file);
    }
})

I wouldn't recommend storing the images as data URIs in your markdown document, this is just a simple example. The file variable is a File object: https://developer.mozilla.org/en-US/docs/Web/API/File.

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

Successfully merging a pull request may close this issue.

2 participants