From 583220acca483e567553851815d3563bec7468f6 Mon Sep 17 00:00:00 2001 From: Viatrix Date: Thu, 12 Mar 2026 12:15:13 -0700 Subject: Added error message for image with zero hyperlinks --- imagemap.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/imagemap.py b/imagemap.py index e595f08..22789f0 100644 --- a/imagemap.py +++ b/imagemap.py @@ -1,6 +1,7 @@ import inkex from inkex import bezier from inkex.command import inkscape_command +from inkex.localization import inkex_gettext as _ # (X)HTML stuff: ESCAPE=str.maketrans({'&':'&','<':'<','>':'>'}) @@ -64,6 +65,8 @@ class ImageMap(inkex.OutputExtension): style=el.effective_style() style[CSS_LINK_INDEX]=f'" {CSS_LINK_INDEX}-{len(links)} "' 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)"))) command=\ ';'.join(f'select-clear;select-by-selector:[style~="{CSS_LINK_INDEX}-{i}"];object-stroke-to-path;path-union;object-set-attribute:style,{CSS_LINK_INDEX}:" {CSS_LINK_INDEX}-{i} "' for i in range(len(links))) \ +';select-all;path-flatten;path-split' -- cgit