Option controlling autoplay of audio dropped into card editing window

Using this is a bit complicated since you have to build dependencies and run from source.

I think this can be done with an add-on. I’ll do that and return to you later.

Update:

Copy the code below to a file named __init__.py and put it in a folder called something like editor_no_autoplay, then copy that folder to your addons21 folder found in Anki’s data folder.

import html
import urllib.parse

from aqt.editor import Editor, pics

def myFnameToLink(self, fname: str) -> str:
    ext = fname.split(".")[-1].lower()
    if ext in pics:
        name = urllib.parse.quote(fname.encode("utf8"))
        return '<img src="%s">' % name
    else:
        return "[sound:%s]" % html.escape(fname, quote=False)

Editor.fnameToLink = myFnameToLink
3 Likes