Closed jlumbroso closed 5 years ago
I took a closer look at an existing example of an Anki deck with embedded images: https://ankiweb.net/shared/info/1226689493
It seems that my issue was that the images need to be embedded directly as "Fields" not within "Models", the path to media files can apparently not be referenced from anything besides Field.
Two small changes to my minimal example now produce a deck that correctly displays images: https://gist.github.com/jlumbroso/e17abff02d89be04240072191af09ab2
In hindsight, I think that what was a bit misleading was this part of the README.md:
[...] They can be referenced in notes like this:
[sound:sound.mp3] <img src="image.jpg">
[...]
No, media files cannot (apparently?) be referenced in notes in that way, they must stored in a field, such as "Mediafile" and then referenced in notes by that field "{{Mediafile}}". It may be worth adjusting the wording to better reflect that (and I can suggest a pull request if that is helpful).
Thanks! I will update the README regarding this.
This is documented in the Anki manual, but I agree that the genanki README could have been clearer.
I updated the README: https://github.com/kerrickstaley/genanki/commit/0181c0485b43612dd4280b734dfa52cce11eae6b
This library is really a convenient way to create decks! I am trying to create decks programmatically to learn the names of my students (https://github.com/jlumbroso/tiger-anki). As such, I am trying to associate names to images and vice-versa.
This seems to be a perfect use of the
media_files
attribute. However, every attempt I have made, results in a deck in which Anki displays all images as "broken images."I have attached a minimal reproducible example,
test.py
, on my system with Python 3.6, Anki 2.1.4 and genanki 0.6.0 (installed with pip). It generates anoutput.apkg
deck, with a single card that produces one of these broken links.When I unzip the deck, it seems like the
media
file is encoded appropriately following the format specs:http://decks.wikia.com/wiki/Anki_APKG_format_documentation#Media_Formatting
I am not sure what is the wrong, or whether it is an issue with genanki or anki.
I created a minimal example in the following gist: https://gist.github.com/jlumbroso/60971ec65324603c0ab2efd02fd8098b
which will generate the deck
python3 genanki-media-test.py
.The file I have included as an example image
format.jpg
is:But any JPG image would do.