From 0204c69d23859cf423d5d36c6374b3c7fc925fce Mon Sep 17 00:00:00 2001 From: sasilver Date: Wed, 9 Jul 2008 17:51:46 +0000 Subject: [PATCH] Some fixes for the Embed All Images extension: 1) Cope with missing xlink:href. (Fixes bug 246724.) 2) Don't ignore images with filenames that begin with "data". 3) Remove an unused line. 4) Suppress part of an error message in cases where it makes no sense. --- share/extensions/embedimage.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/share/extensions/embedimage.py b/share/extensions/embedimage.py index ab903a18e..93472b325 100644 --- a/share/extensions/embedimage.py +++ b/share/extensions/embedimage.py @@ -53,10 +53,9 @@ class Embedder(inkex.Effect): def embedImage(self, node): xlink = node.get(inkex.addNS('href','xlink')) - if (xlink[:4]!='data'): + if xlink is None or xlink[:5] != 'data:': absref=node.get(inkex.addNS('absref','sodipodi')) href=xlink - svg=self.document.getroot().xpath('/svg:svg', namespaces=inkex.NSS)[0] path='' #path selection strategy: # 1. href if absolute @@ -70,9 +69,12 @@ class Embedder(inkex.Effect): if (not os.path.isfile(path)): if (absref != None): path=absref + if (not os.path.isfile(path)): inkex.errormsg(_('No xlink:href or sodipodi:absref attributes found, or they do not point to an existing file! Unable to embed image.')) - + if path: + inkex.errormsg(_("Sorry we could not locate %s") % path) + if (os.path.isfile(path)): file = open(path,"rb").read() embed=True @@ -97,8 +99,6 @@ class Embedder(inkex.Effect): del node.attrib[inkex.addNS('absref',u'sodipodi')] else: inkex.errormsg(_("%s is not of type image/png, image/jpeg, image/bmp, image/gif, image/tiff, or image/x-icon") % path) - else: - inkex.errormsg(_("Sorry we could not locate %s") % path) if __name__ == '__main__': e = Embedder() -- 2.30.2