Skip to content

Commit

Permalink
SVG-File: avoid attr error on missing dimensions (#1157)
Browse files Browse the repository at this point in the history
  • Loading branch information
drfho committed Sep 21, 2023
1 parent 4b714a2 commit 05f81d9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/OFS/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 05f81d9

Please sign in to comment.