# HG changeset patch # User Thierry Florac # Date 1505129217 -7200 # Node ID 277260b46bc7fd657d9128a6c9dfe71048ea4adb # Parent 30e0a305f75f339a739c66c3d9e25b4f71229c65 Updated thumbnailer interface diff -r 30e0a305f75f -r 277260b46bc7 src/pyams_file/image.py --- a/src/pyams_file/image.py Mon Sep 11 13:26:15 2017 +0200 +++ b/src/pyams_file/image.py Mon Sep 11 13:26:57 2017 +0200 @@ -27,6 +27,8 @@ from zope.interface import implementer from zope.schema.fieldproperty import FieldProperty +from pyams_file import _ + WEB_FORMATS = ('JPEG', 'PNG', 'GIF') THUMB_SIZE = re.compile('^(?:\w+\:)?([0-9]+)x([0-9]+)$') @@ -49,6 +51,10 @@ class ImageThumbnailer(ContextAdapter): """Image thumbnailer adapter""" + label = _("Default thumbnail") + section = _("Default thumbnail") + weight = 1 + def get_default_geometry(self, options=None): """Default thumbnail geometry""" geometry = ThumbnailGeometry() @@ -91,6 +97,8 @@ class ImageSelectionThumbnailer(ImageThumbnailer): """Image thumbnailer based on user selection""" + section = _("Custom selections") + def create_thumbnail(self, target, format=None): # get thumbnail size if isinstance(target, str): @@ -138,6 +146,9 @@ class ImageSquareThumbnailer(ImageSelectionThumbnailer): """Image square thumbnail adapter""" + label = _("Square thumbnail") + weight = 5 + def get_default_geometry(self, options=None): """Default square thumbnail geometry""" geometry = ThumbnailGeometry() @@ -159,6 +170,9 @@ class ImagePanoThumbnailer(ImageSelectionThumbnailer): """Image panoramic thumbnail adapter""" + label = _("Panoramic thumbnail") + weight = 6 + def get_default_geometry(self, options=None): """Default panoramic thumbnail geometry""" geometry = ThumbnailGeometry() @@ -190,22 +204,36 @@ class ResponsiveImageThumbnailer(ImageSelectionThumbnailer): """Responsive image thumbnailer""" + section = _("Responsive selections") + @adapter_config(name='xs', context=IResponsiveImage, provides=IThumbnailer) class XsImageThumbnailer(ResponsiveImageThumbnailer): """eXtra-Small responsive image thumbnailer""" + label = _("Smartphone thumbnail") + weight = 10 + @adapter_config(name='sm', context=IResponsiveImage, provides=IThumbnailer) class SmImageThumbnailer(ResponsiveImageThumbnailer): """SMall responsive image thumbnailer""" + label = _("Tablet thumbnail") + weight = 11 + @adapter_config(name='md', context=IResponsiveImage, provides=IThumbnailer) class MdImageThumbnailer(ResponsiveImageThumbnailer): """MeDiumresponsive image thumbnailer""" + label = _("Medium screen thumbnail") + weight = 12 + @adapter_config(name='lg', context=IResponsiveImage, provides=IThumbnailer) class LgImageThumbnailer(ResponsiveImageThumbnailer): """LarGe responsive image thumbnailer""" + + label = _("Large screen thumbnail") + weight = 13 diff -r 30e0a305f75f -r 277260b46bc7 src/pyams_file/interfaces/__init__.py --- a/src/pyams_file/interfaces/__init__.py Mon Sep 11 13:26:15 2017 +0200 +++ b/src/pyams_file/interfaces/__init__.py Mon Sep 11 13:26:57 2017 +0200 @@ -199,6 +199,10 @@ class IThumbnailer(Interface): """Interface of adapter used to generate image thumbnails""" + label = Attribute("Thumbnail label") + section = Attribute("Thumbnail section") + weight = Attribute("Thumbnail weight") + def get_default_geometry(self): """Get default thumbnail geometry""" @@ -279,3 +283,7 @@ These forms have a custom context permission checker. """ + + +class IThumbnailForm(IFileModifierForm): + """Image thumbnail selection form marker interface""" diff -r 30e0a305f75f -r 277260b46bc7 src/pyams_file/thumbnail.py --- a/src/pyams_file/thumbnail.py Mon Sep 11 13:26:15 2017 +0200 +++ b/src/pyams_file/thumbnail.py Mon Sep 11 13:26:57 2017 +0200 @@ -256,4 +256,4 @@ def render(self, context=None): if context is None: context = self.context - return IThumbnail(context) + return IThumbnail(context, None)