mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer: Fix images embedded inside svg tags not available for viewing in a popup
This commit is contained in:
parent
f4f265e6ec
commit
87ab6fa448
@ -347,6 +347,7 @@ def transform_html(container, name, virtualize_resources, link_uid, link_to_map,
|
|||||||
link_xpath = XPath('//h:a[@href]')
|
link_xpath = XPath('//h:a[@href]')
|
||||||
svg_link_xpath = XPath('//svg:a')
|
svg_link_xpath = XPath('//svg:a')
|
||||||
img_xpath = XPath('//h:img[@src]')
|
img_xpath = XPath('//h:img[@src]')
|
||||||
|
svg_img_xpath = XPath('//svg:image[@xl:href]')
|
||||||
res_link_xpath = XPath('//h:link[@href]')
|
res_link_xpath = XPath('//h:link[@href]')
|
||||||
root = container.parsed(name)
|
root = container.parsed(name)
|
||||||
changed_names = set()
|
changed_names = set()
|
||||||
@ -357,6 +358,10 @@ def transform_html(container, name, virtualize_resources, link_uid, link_to_map,
|
|||||||
img_name = container.href_to_name(img.get('src'), name)
|
img_name = container.href_to_name(img.get('src'), name)
|
||||||
if img_name:
|
if img_name:
|
||||||
img.set('data-calibre-src', img_name)
|
img.set('data-calibre-src', img_name)
|
||||||
|
for img in svg_img_xpath(root):
|
||||||
|
img_name = container.href_to_name(img.get(XLINK('href')), name)
|
||||||
|
if img_name:
|
||||||
|
img.set('data-calibre-src', img_name)
|
||||||
|
|
||||||
# Disable non-stylesheet link tags. This link will not be loaded by the
|
# Disable non-stylesheet link tags. This link will not be loaded by the
|
||||||
# browser anyway and will causes the resource load check to hang
|
# browser anyway and will causes the resource load check to hang
|
||||||
|
@ -10,9 +10,10 @@ def get_elements(x, y):
|
|||||||
nonlocal img_id_counter
|
nonlocal img_id_counter
|
||||||
ans = {'link': None, 'img': None, 'highlight': None, 'crw': None}
|
ans = {'link': None, 'img': None, 'highlight': None, 'crw': None}
|
||||||
for elem in document.elementsFromPoint(x, y):
|
for elem in document.elementsFromPoint(x, y):
|
||||||
if elem.tagName.toLowerCase() is 'a' and elem.getAttribute('href') and not ans.link:
|
tl = elem.tagName.toLowerCase()
|
||||||
|
if tl is 'a' and elem.getAttribute('href') and not ans.link:
|
||||||
ans.link = elem.getAttribute('href')
|
ans.link = elem.getAttribute('href')
|
||||||
elif elem.tagName.toLowerCase() is 'img' and elem.getAttribute('data-calibre-src') and not ans.img:
|
elif (tl is 'img' or tl is 'image') and elem.getAttribute('data-calibre-src') and not ans.img:
|
||||||
ans.img = elem.getAttribute('data-calibre-src')
|
ans.img = elem.getAttribute('data-calibre-src')
|
||||||
elif elem.dataset?.calibreRangeWrapper:
|
elif elem.dataset?.calibreRangeWrapper:
|
||||||
ans.crw = elem.dataset.calibreRangeWrapper
|
ans.crw = elem.dataset.calibreRangeWrapper
|
||||||
|
Loading…
x
Reference in New Issue
Block a user