--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_file/skin/__init__.py Thu Dec 20 09:59:19 2018 +0100
@@ -0,0 +1,63 @@
+#
+# Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+from pyramid.renderers import render
+from zope.interface import Interface
+
+from pyams_utils.adapter import ContextRequestViewAdapter, adapter_config
+from pyams_utils.interfaces.tales import ITALESExtension
+
+
+#
+# Responsive 'picture' TALES extension
+#
+
+@adapter_config(name='picture',
+ context=(Interface, Interface, Interface),
+ provides=ITALESExtension)
+class PictureTALESExtension(ContextRequestViewAdapter):
+ """Picture TALES adapter
+
+ This TALES adapter can be used to automatically create a 'picture' HTML tag
+ embedding all image attributes.
+ """
+
+ def render(self, context=None, lg_thumb='lg', lg_width=12, md_thumb='md', md_width=12,
+ sm_thumb='sm', sm_width=12, xs_thumb='xs', xs_width=12, alt='', css_class=''):
+ if context is None:
+ context = self.context
+ 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)
\ No newline at end of file