# HG changeset patch # User Thierry Florac # Date 1540391386 -7200 # Node ID 50da03e1114f127adc885d2d1ebe64370c216c2f # Parent 015342e304c875ccdda0e68b9fedeb44ba6c2e32 Updated "picture" TALES extension to also handle SVG images diff -r 015342e304c8 -r 50da03e1114f src/pyams_file/image.py --- a/src/pyams_file/image.py Wed Oct 24 09:26:47 2018 +0200 +++ b/src/pyams_file/image.py Wed Oct 24 16:29:46 2018 +0200 @@ -262,16 +262,27 @@ sm_thumb='sm', sm_width=12, xs_thumb='xs', xs_width=12, alt='', css_class=''): if context is None: context = self.context - return render('templates/picture.pt', - {'image': context, - 'lg_thumb': lg_thumb, - 'lg_width': lg_width, - 'md_thumb': md_thumb, - 'md_width': md_width, - 'sm_thumb': sm_thumb, - 'sm_width': sm_width, - 'xs_thumb': xs_thumb, - 'xs_width': xs_width, - 'alt': alt, - 'css_class': css_class}, - request=self.request) + if context.content_type.startswith('image/svg'): + return render('templates/svg-picture.pt', + {'image': context, + 'lg_width': lg_width, + 'md_width': md_width, + 'sm_width': sm_width, + 'xs_width': xs_width, + 'alt': alt, + 'css_class': css_class}, + request=self.request) + else: + return render('templates/picture.pt', + {'image': context, + 'lg_thumb': lg_thumb, + 'lg_width': lg_width, + 'md_thumb': md_thumb, + 'md_width': md_width, + 'sm_thumb': sm_thumb, + 'sm_width': sm_width, + 'xs_thumb': xs_thumb, + 'xs_width': xs_width, + 'alt': alt, + 'css_class': css_class}, + request=self.request) diff -r 015342e304c8 -r 50da03e1114f src/pyams_file/templates/picture.pt --- a/src/pyams_file/templates/picture.pt Wed Oct 24 09:26:47 2018 +0200 +++ b/src/pyams_file/templates/picture.pt Wed Oct 24 16:29:46 2018 +0200 @@ -10,8 +10,8 @@ timestamp tales:timestamp(thumb);" srcset="${image_url}/++thumb++${xs_thumb}:w${width}?_=${timestamp}" /> - @@ -21,8 +21,8 @@ timestamp tales:timestamp(thumb);" srcset="${image_url}/++thumb++${sm_thumb}:w${width}?_=${timestamp}" /> - @@ -32,8 +32,8 @@ timestamp tales:timestamp(thumb);" srcset="${image_url}/++thumb++${md_thumb}:w${width}?_=${timestamp}" /> - @@ -43,8 +43,8 @@ timestamp tales:timestamp(thumb);" srcset="${image_url}/++thumb++${lg_thumb}:w${width}?_=${timestamp}" /> - + + + + + + ${alt} +