Added checks on responsive images
authorThierry Florac <thierry.florac@onf.fr>
Tue, 06 Feb 2018 13:56:35 +0100
changeset 359 b21d74ececb1
parent 358 d959b670cbe1
child 360 e47b68b41f06
Added checks on responsive images
src/pyams_content/component/extfile/__init__.py
src/pyams_content/component/gallery/file.py
src/pyams_content/component/illustration/__init__.py
--- a/src/pyams_content/component/extfile/__init__.py	Tue Feb 06 11:39:00 2018 +0100
+++ b/src/pyams_content/component/extfile/__init__.py	Tue Feb 06 13:56:35 2018 +0100
@@ -22,7 +22,7 @@
     IExtMedia
 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
 from pyams_content.shared.common.interfaces import IWfSharedContent
-from pyams_file.interfaces import IFileInfo, IResponsiveImage, DELETED_FILE
+from pyams_file.interfaces import IFileInfo, IImage, IResponsiveImage
 from pyams_i18n.interfaces import II18n, INegotiator, II18nManager
 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent, IObjectRemovedEvent
 
@@ -230,7 +230,7 @@
     def data(self, value):
         self._data = value
         for data in value.values():
-            if (data is not None) and (data is not DELETED_FILE):
+            if IImage.providedBy(data):
                 alsoProvides(data, IResponsiveImage)
 
 register_file_factory('image', ExtImage, _("Image"))
--- a/src/pyams_content/component/gallery/file.py	Tue Feb 06 11:39:00 2018 +0100
+++ b/src/pyams_content/component/gallery/file.py	Tue Feb 06 13:56:35 2018 +0100
@@ -19,7 +19,7 @@
 from pyams_content.component.gallery.interfaces import IGalleryFile
 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
 from pyams_content.shared.common.interfaces import IWfSharedContent
-from pyams_file.interfaces import DELETED_FILE, IResponsiveImage
+from pyams_file.interfaces import DELETED_FILE, IResponsiveImage, IImage
 from pyams_form.interfaces.form import IFormContextPermissionChecker
 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator
 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent, IObjectRemovedEvent
@@ -67,7 +67,7 @@
     @data.setter
     def data(self, value):
         self._data = value
-        if (value is not None) and (value is not DELETED_FILE):
+        if IImage.providedBy(value):
             alsoProvides(self._data, IResponsiveImage)
 
 
--- a/src/pyams_content/component/illustration/__init__.py	Tue Feb 06 11:39:00 2018 +0100
+++ b/src/pyams_content/component/illustration/__init__.py	Tue Feb 06 13:56:35 2018 +0100
@@ -19,7 +19,7 @@
 from pyams_content.component.illustration.interfaces import IIllustrationRenderer, IIllustration, IIllustrationTarget, \
     ILLUSTRATION_KEY
 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
-from pyams_file.interfaces import DELETED_FILE, IResponsiveImage, IFileInfo
+from pyams_file.interfaces import IFileInfo, IImage, IResponsiveImage
 from pyams_i18n.interfaces import INegotiator, II18n, II18nManager
 from zope.annotation.interfaces import IAnnotations
 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent
@@ -68,7 +68,7 @@
     def data(self, value):
         self._data = value
         for data in value.values():
-            if (data is not None) and (data is not DELETED_FILE):
+            if IImage.providedBy(data):
                 alsoProvides(data, IResponsiveImage)