Open
Description
This idea is by brumar
Currently, images are not supported and selected text is cleaned while adding from chrome menu.
The goal is to allow user to send image along with text.
Images
If you drag and drop an image, it is base64 encoded by the medium editor and displayed as
concept
Adding images to Anki
Anki stores all images in media folder and these are sent in a separate request using ankiConnect.
The sample request is
{
"action": "storeMediaFile",
"version": 6,
"params": {
"filename": "_hello.txt",
"data": "SGVsbG8sIHdvcmxkIQ=="
}
}
The result is standard like any other request to ankiConnect.
{
"result": null,
"error": null
}
process
Before Submitting data.
- parse body of each field data.
sample of 1px black base64 encode image
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=">
- . if imageFound, Generate a random file name based + extension based on image/gif or png or jpg.
submit the request to ankiConnect
sendRequest
"params": {
"filename": "image992.png",
"data": "SGVsbG8sIHdvcmxkIQ=="
}
If successful, replace the image source in the note with the filename
else
delete the image from note body.