aboutsummaryrefslogtreecommitdiff
path: root/mammoth
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-09-02 23:23:08 +0100
committerMichael Williamson <mike@zwobble.org>2016-09-02 23:23:08 +0100
commit7018a91184e98a47c0a39526c743cd9968450633 (patch)
treea388a9128cbd6049f40b14ed92dbd280b4473184 /mammoth
parent1727ae617084af57c3b690da36b990dcce9b72d4 (diff)
Use alt text title if description is blank or missing
Diffstat (limited to 'mammoth')
-rw-r--r--mammoth/docx/body_xml.py6
1 files changed, 5 insertions, 1 deletions
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") \