mwilliamson / python-mammoth

Convert Word documents (.docx files) to HTML
BSD 2-Clause "Simplified" License
785 stars 121 forks source link

Can you change image alt text when converting from docx? #103

Closed mattl1598 closed 2 years ago

mattl1598 commented 3 years ago

I've written my own image converter function based on the example one in order to store the image in a database and display it with the right "src" but I can't find the right key for changing the alt text from the original file path that word stores.

I've tried "alt", "alt_text" and "title" to no avail.

(question)

mwilliamson commented 3 years ago

At the moment, this isn't supported: the alt text will always be taken from the original document if it's available.

mattl1598 commented 2 years ago

An update to this issue, the newest version of word automatically generates alt text with AI and uses line breaks which causes rendering issues with the resulting markdown. I'm working on a fix for my original issue and this new one currently.

image

mwilliamson commented 2 years ago

As of 1.5.0, you can override the alt text by adding an "alt" entry to the returned dict.