From 7018a91184e98a47c0a39526c743cd9968450633 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 2 Sep 2016 23:23:08 +0100 Subject: Use alt text title if description is blank or missing --- mammoth/docx/body_xml.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'mammoth') diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py index b1be2e5..fbf813c 100644 --- a/mammoth/docx/body_xml.py +++ b/mammoth/docx/body_xml.py @@ -269,7 +269,11 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f return _success(documents.line_break()) def inline(element): - alt_text = element.find_child_or_null("wp:docPr").attributes.get("descr") + properties = element.find_child_or_null("wp:docPr").attributes + if properties.get("descr", "").strip(): + alt_text = properties.get("descr") + else: + alt_text = properties.get("title") blips = element.find_children("a:graphic") \ .find_children("a:graphicData") \ .find_children("pic:pic") \ -- cgit v1.2.3