medium-editor
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
Description
[Description of the bug or feature]
Steps to reproduce
- [First step]
- [Second step]
- [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:
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 Can that also handle multiple images at the same time? Also does this mean you have to disable drag-and-drop ?