diff options
| author | Michael Williamson <mike@zwobble.org> | 2013-12-14 16:50:19 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2013-12-14 16:50:19 +0000 |
| commit | a96ab058644e43bb5fdf32c0b3b238e1a9e1360f (patch) | |
| tree | 2cf713367b8ef656571da1203f7945b1c37f6924 /mammoth | |
| parent | 93e945c2ca0b1118c8e119a09988d8b4093625d8 (diff) | |
Use image alt text if available
Diffstat (limited to 'mammoth')
| -rw-r--r-- | mammoth/conversion.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/mammoth/conversion.py b/mammoth/conversion.py index 5580925..635b57c 100644 --- a/mammoth/conversion.py +++ b/mammoth/conversion.py @@ -77,10 +77,14 @@ class DocumentConverter(object): output = io.BytesIO() base64.encode(image_bytes, output) encoded_src = output.getvalue().rstrip("\n") - - html_generator.self_closing("img", { + + attributes = { "src": "data:{0};base64,{1}".format(image.content_type, encoded_src) - }) + } + if image.alt_text: + attributes["alt"] = image.alt_text + + html_generator.self_closing("img", attributes) def _convert_elements_to_html(self, elements, html_generator): |
