--- a/src/pyams_content/shared/imagemap/zmi/area.py Wed Jun 14 15:19:03 2017 +0200
+++ b/src/pyams_content/shared/imagemap/zmi/area.py Wed Jun 14 15:19:38 2017 +0200
@@ -9,6 +9,7 @@
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
+from pyams_i18n.interfaces import II18n
__docformat__ = 'restructuredtext'
@@ -62,7 +63,20 @@
"""Imagemap area add form"""
legend = _("Add new image area")
- dialog_class = 'modal-large'
+
+ @property
+ def dialog_class(self):
+ image = II18n(self.context).query_attribute('image', request=self.request)
+ if image is not None:
+ width = image.get_image_size()[0]
+ if width > 1000:
+ return 'modal-max'
+ elif width > 800:
+ return 'modal-xlarge'
+ else:
+ return 'modal-large'
+ else:
+ return 'modal-large'
fields = field.Fields(IImageMapArea)
fields['link'].widgetFactory = SingleLinkLinkSelectFieldWidget
@@ -92,7 +106,20 @@
"""Image map area properties edit form"""
legend = _("Edit image map properties")
- dialog_class = 'modal-large'
+
+ @property
+ def dialog_class(self):
+ image = II18n(self.context.__parent__).query_attribute('image', request=self.request)
+ if image is not None:
+ width = image.get_image_size()[0]
+ if width > 1000:
+ return 'modal-max'
+ elif width > 800:
+ return 'modal-xlarge'
+ else:
+ return 'modal-large'
+ else:
+ return 'modal-large'
fields = field.Fields(IImageMapArea)
fields['link'].widgetFactory = SingleLinkLinkSelectFieldWidget