From f4f265e6ec6b4f8e6100f3f8d372b2dde52455da Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 4 Apr 2023 10:18:27 +0530 Subject: [PATCH] DOCX Input: Dont ignore images that are present as fallbacks for a word drawing object. Fixes #2013972 [Pictures disappearing](https://bugs.launchpad.net/calibre/+bug/2013972) --- src/calibre/ebooks/docx/to_html.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/calibre/ebooks/docx/to_html.py b/src/calibre/ebooks/docx/to_html.py index e2a4d7da8a..81a181996d 100644 --- a/src/calibre/ebooks/docx/to_html.py +++ b/src/calibre/ebooks/docx/to_html.py @@ -279,6 +279,13 @@ class Convert: if fallbacks: for choice in choices: ac.remove(choice) + if len(fallbacks) == 1 and ac.getparent().tag.endswith('}r') and len(fallbacks[0]) == 1: + q = fallbacks[0][0] + if q.tag and (q.tag.endswith('}drawing') or q.tag.endswith('}pict')): + p = ac.getparent() + idx = p.index(ac) + p.insert(idx, q) + p.remove(ac) def read_styles(self, relationships_by_type):