--- a/src/pyams_file/image.py Tue Sep 08 12:22:26 2020 +0200
+++ b/src/pyams_file/image.py Wed Sep 23 16:44:12 2020 +0200
@@ -293,18 +293,19 @@
else:
options['style'] = ''
options['css_class'] = css_class
- svg = image.data
- if alt:
- svg = PyQuery(svg)
- g = PyQuery('<g></g>')
- g.append(PyQuery('<title />').text(alt))
- for child in svg.children():
- g.append(child)
- svg.empty().append(g)
- svg = svg.outer_html()
- if img_class:
- svg.attr('class', img_class)
- options['svg'] = svg
+ if alt or img_class:
+ svg = PyQuery(image.data)
+ if alt:
+ g = PyQuery('<g></g>')
+ g.append(PyQuery('<title />').text(alt))
+ for child in svg.children():
+ g.append(child)
+ svg.empty().append(g)
+ if img_class:
+ svg.attr('class', img_class)
+ options['svg'] = svg.outer_html()
+ else:
+ options['svg'] = image.data
return render('templates/svg-render.pt', options, request)