medium-editor icon indicating copy to clipboard operation
medium-editor copied to clipboard

How to Change Image upload path in medium editor or Is ther any way of writing own upload image code

Open AnilKumarSamal opened this issue 6 years ago • 2 comments

Description

[Description of the bug or feature]

Steps to reproduce

  1. [First step]
  2. [Second step]
  3. [and so on...]

Expected behavior: [What you expected to happen]

Actual behavior: [What actually happened]

Link to an example: [If you're reporting a bug that's not reproducible on our demo page, please try to reproduce it on JSFiddle, JS Bin, CodePen or a similar service and paste a link here]

Versions

  • medium-editor:
  • browser:
  • OS:

AnilKumarSamal avatar Apr 26 '18 08:04 AnilKumarSamal

What I did, I created a custom button like this:


{
                                    name: "image",
                                    action: () => {
                                        document.getElementById("editor_image").click();
                                    },
                                    aria: "image",
                                    contentDefault: `<img src=${image} alt=""/>`
                                },

As part of buttons. Then somewhere within my page created an input with type of file

<input type="file" id="editor_image" name="editor_image" onChange={this._handleFileUpload} />

on change attached a callback function and handled file upload there. Uploaded to the server and on response, used editor instance and pasted html back in.

Hope this helps someone, as it took me a while to figure this out :D Simple enough in the end but nerve wrecking when trying to figure it out

slegaitis avatar Apr 28 '18 17:04 slegaitis

@slegaitis Can that also handle multiple images at the same time? Also does this mean you have to disable drag-and-drop ?

BenjaminHoegh avatar Oct 24 '21 18:10 BenjaminHoegh