# HG changeset patch # User Thierry Florac # Date 1600872252 -7200 # Node ID 9d0a2eaf976c89b006daedcc66bd47e42f92dc77 # Parent aca9fe23b7733ee8d73f9e7521da6865e72ac11e Updated SVG image renderer diff -r aca9fe23b773 -r 9d0a2eaf976c src/pyams_file/image.py --- 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.append(PyQuery('').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)