src/pyams_file/image.py
changeset 212 9d0a2eaf976c
parent 209 b146beab5367
equal deleted inserted replaced
211:aca9fe23b773 212:9d0a2eaf976c
   291             width, 'px' if isinstance(width, int) else '',
   291             width, 'px' if isinstance(width, int) else '',
   292             height, 'px' if isinstance(height, int) else '')
   292             height, 'px' if isinstance(height, int) else '')
   293     else:
   293     else:
   294         options['style'] = ''
   294         options['style'] = ''
   295     options['css_class'] = css_class
   295     options['css_class'] = css_class
   296     svg = image.data
   296     if alt or img_class:
   297     if alt:
   297         svg = PyQuery(image.data)
   298         svg = PyQuery(svg)
   298         if alt:
   299         g = PyQuery('<g></g>')
   299             g = PyQuery('<g></g>')
   300         g.append(PyQuery('<title />').text(alt))
   300             g.append(PyQuery('<title />').text(alt))
   301         for child in svg.children():
   301             for child in svg.children():
   302             g.append(child)
   302                 g.append(child)
   303         svg.empty().append(g)
   303             svg.empty().append(g)
   304         svg = svg.outer_html()
   304         if img_class:
   305     if img_class:
   305             svg.attr('class', img_class)
   306         svg.attr('class', img_class)
   306         options['svg'] = svg.outer_html()
   307     options['svg'] = svg
   307     else:
       
   308         options['svg'] = image.data
   308     return render('templates/svg-render.pt', options, request)
   309     return render('templates/svg-render.pt', options, request)
   309 
   310 
   310 
   311 
   311 def render_img(image, width=None, height=None, request=None,
   312 def render_img(image, width=None, height=None, request=None,
   312                css_class='', img_class='', timestamp=False, alt=''):
   313                css_class='', img_class='', timestamp=False, alt=''):