# A confusing bug in the process of making my own Anki addon

**URL:** <https://forums.ankiweb.net/t/a-confusing-bug-in-the-process-of-making-my-own-anki-addon/6418>\
**Category:** Add-ons\
**Created:** [January 11, 2021, 11:25am UTC](https://forums.ankiweb.net/t/a-confusing-bug-in-the-process-of-making-my-own-anki-addon/6418 "2021-01-11T11:25:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![woodson](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@woodson](https://forums.ankiweb.net/u/woodson)\
**Post date:** [January 11, 2021, 11:25am UTC](https://forums.ankiweb.net/t/a-confusing-bug-in-the-process-of-making-my-own-anki-addon/6418/1 "2021-01-11T11:25:49Z")

</div>

I use a Python module genanki to generate cards.But the image is always broken in the card.  
My code are as follow  
.  
‘’’  
import genanki

my\_model = genanki.Model(  
1091735104,  
‘Simple Model with Media’,  
fields=[  
{‘name’: ‘Question’},  
{‘name’: ‘Answer’},  
{‘name’: ‘MyMedia’},  
{‘name’: ‘MyAnswerMedia’} # ADD THIS  
],  
templates=[  
{  
‘name’: ‘Card 1’,  
‘qfmt’: ‘{{Question}}  
{{MyAnswerMedia}}’, # AND THIS  
‘afmt’: ‘{{FrontSide}}

* * *
{{MyMedia}}  
{{Answer}}’,  
},  
])

deckname = “newDeck”  
decknumber = 987655  
my\_deck = genanki.Deck(  
decknumber,  
deckname)

my\_note=genanki.Note(  
model=my\_model,  
fields=[“test”,“test”, ‘ ![]()’,“test”])  
my\_deck.add\_note(my\_note)

my\_package = genanki.Package(my\_deck)  
my\_package.media\_files = [“img\_2991.jpg”]  
genanki.Package(my\_deck).write\_to\_file(deckname + r".apkg")  
‘’’

By the way when I check the media file within apkg file and open it with notebook,it simply contain a {}.Can someone help me?

---

<div class="post-metadata">

**Author:** ![hengiesel](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/hengiesel/32/920_2.png) [@hengiesel](https://forums.ankiweb.net/u/hengiesel)\
**Post date:** [January 11, 2021, 12:21pm UTC](https://forums.ankiweb.net/t/a-confusing-bug-in-the-process-of-making-my-own-anki-addon/6418/2 "2021-01-11T12:21:06Z")

</div>

I recommend posting this in the [repository of the developer](https://github.com/kerrickstaley/genanki/issues).

---

<div class="post-metadata">

**Author:** ![woodson](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@woodson](https://forums.ankiweb.net/u/woodson)\
**Post date:** [January 11, 2021, 12:27pm UTC](https://forums.ankiweb.net/t/a-confusing-bug-in-the-process-of-making-my-own-anki-addon/6418/3 "2021-01-11T12:27:27Z")

</div>

Thanks a lot.I will do this.
