--- a/src/pyams_file/image.py Wed Oct 24 16:34:49 2018 +0200
+++ b/src/pyams_file/image.py Sun Nov 11 17:11:35 2018 +0100
@@ -206,6 +206,16 @@
return round(ratio * thumb_size[0]), round(ratio * thumb_size[1])
+@adapter_config(name='banner', context=IImage, provides=IThumbnailer)
+class ImageBannerThumbnailer(ImageRatioThumbnailer):
+ """Image banner thumbnail adapter"""
+
+ label = _("Banner thumbnail")
+ weight = 8
+
+ ratio = (5, 1)
+
+
class ResponsiveImageThumbnailer(ImageSelectionThumbnailer):
"""Responsive image thumbnailer"""
--- a/src/pyams_file/zmi/image.py Wed Oct 24 16:34:49 2018 +0200
+++ b/src/pyams_file/zmi/image.py Sun Nov 11 17:11:35 2018 +0100
@@ -459,6 +459,54 @@
#
+# Image banner thumbnail selection
+#
+
+@viewlet_config(name='image.thumb.banner.action', context=IImage, layer=IAdminLayer, view=IMediaWidget,
+ manager=IContextActions, weight=70)
+class ImageBannerThumbnailAction(FileModifierAction):
+ """Banner thumbnail image selection"""
+
+ _label = _("Select banner thumbnail...")
+
+ @property
+ def label(self):
+ return '<div>{label}</div><div class="padding-y-5"><img src="{url}/++thumb++banner:200x128?_=" ' \
+ '/></div>'.format(label=self.request.localizer.translate(self._label),
+ url=absolute_url(self.context, self.request))
+
+ label_css_class = 'fa fa-fw-md fa-window-minimize fa-rotate-180'
+
+ url = 'banner-thumbnail.html'
+ modal_target = True
+
+
+@pagelet_config(name='banner-thumbnail.html', context=IImage, layer=IPyAMSLayer, permission=VIEW_PERMISSION)
+@ajax_config(name='banner-thumbnail.json', context=IImage, layer=IPyAMSLayer, permission=VIEW_PERMISSION)
+@implementer(IThumbnailForm)
+class ImageBannerThumbnailEditForm(ImageSelectionThumbnailEditForm):
+ """Image banner thumbnail edit form"""
+
+ prefix = 'image_banner.'
+
+ legend = _("Select banner thumbnail")
+ icon_css_class = 'fa fa-fw fa-window-minimize fa-rotate-180'
+
+ selection_name = 'banner'
+ selection_ratio = '5:1'
+
+
+@adapter_config(context=(IImage, IAdminLayer, ImageBannerThumbnailEditForm), provides=IFormHelp)
+class ImageBannerThumbnailEditFormHelpAdapter(FormHelp):
+ """Banner image thumbnail edit form help adapter"""
+
+ message = _("""You can use this form to select a banner thumbnail of this image.
+
+**WARNING**: cropping or resizing an image will reset all selected thumbnails and adaptive images!!""")
+ message_format = 'rest'
+
+
+#
# Extra-small devices selection
#