From 4a221e929c7c44b2b133ce4726b6e3e22e1532bf Mon Sep 17 00:00:00 2001 From: drfho Date: Mon, 18 Sep 2023 23:32:19 +0200 Subject: [PATCH] SVG-File: avoid attr error on missing dimensions --- src/OFS/Image.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/OFS/Image.py b/src/OFS/Image.py index 4e933bf661..86e4b2c124 100644 --- a/src/OFS/Image.py +++ b/src/OFS/Image.py @@ -843,6 +843,8 @@ def getImageInfo(data): except Exception: return content_type, width, height for svg in xmldoc.getElementsByTagName('svg'): + w = width + h = height content_type = 'image/svg+xml' if 'height' in svg.attributes and 'width' in svg.attributes: w = svg.attributes['width'].value @@ -866,8 +868,8 @@ def getImageInfo(data): viewBox = [int(float(x)) for x in viewBox.split(' ')] w = viewBox[2] - viewBox[0] h = viewBox[3] - viewBox[1] - width = int(w) - height = int(h) + width = int(w) + height = int(h) return content_type, width, height