aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--imagemap.py6
-rw-r--r--tests/data/svg/image.svg2
2 files changed, 5 insertions, 3 deletions
diff --git a/imagemap.py b/imagemap.py
index 3d25403..8ab6558 100644
--- a/imagemap.py
+++ b/imagemap.py
@@ -62,10 +62,12 @@ class ImageMap(inkex.OutputExtension):
link={attr:AREA_ATTRS[attr](a) for attr in AREA_ATTRS.keys()}
for el in a.iterdescendants(): # CSS is preserved when flattening (for paths)
if not isinstance(el,inkex.ShapeElement): continue
- if el.tag=='{http://www.w3.org/2000/svg}image':
- el.tag='{http://www.w3.org/2000/svg}rect' # because flattening an image creates a clip-path
style=el.effective_style()
style[CSS_LINK_INDEX]=f'" {CSS_LINK_INDEX}-{len(links)} "'
+ if el.tag=='{http://www.w3.org/2000/svg}image':
+ el.tag='{http://www.w3.org/2000/svg}rect' # because flattening an image creates a clip-path
+ style['stroke']='none'
+ style['fill']='#000'
links += [link]
if len(links)==0:
raise inkex.AbortExtension(_("Image has no hyperlinks.\nAdd a hyperlink to an object with right-click → \"{}\".").format(_("Create Anchor (Hyperlink)")))
diff --git a/tests/data/svg/image.svg b/tests/data/svg/image.svg
index e0d62d4..9b970f7 100644
--- a/tests/data/svg/image.svg
+++ b/tests/data/svg/image.svg
@@ -1,6 +1,6 @@
<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Transparent areas of the image should remain part of the link. -->
<a xlink:href="http://example.com">
- <image x="25" y="25" width="50" height="50" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAQAAADYv8WvAAAADUlEQVR42mMAgv9gBAAJAQH/66EXCgAAAABJRU5ErkJggg==" image-rendering="optimizeSpeed"/>
+ <image x="25" y="25" width="50" height="50" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAQAAADYv8WvAAAADUlEQVR42mMAgv9gBAAJAQH/66EXCgAAAABJRU5ErkJggg==" image-rendering="optimizeSpeed" stroke="red" fill="none"/>
</a>
</svg>