Added IBasicIllustration adapter for IImage
authorThierry Florac <thierry.florac@onf.fr>
Tue, 26 Mar 2019 16:47:26 +0100
changeset 1300 95f7277fa500
parent 1299 1a307e6b9432
child 1301 3f8dff132bbb
Added IBasicIllustration adapter for IImage
src/pyams_content/component/illustration/__init__.py
--- a/src/pyams_content/component/illustration/__init__.py	Tue Mar 26 12:33:58 2019 +0100
+++ b/src/pyams_content/component/illustration/__init__.py	Tue Mar 26 16:47:26 2019 +0100
@@ -217,3 +217,26 @@
     """Illustration renderers vocabulary"""
 
     content_interface = IIllustration
+
+
+#
+# Custom image file to illustration adapter
+#
+
+@adapter_config(context=IImage, provides=IBasicIllustration)
+class VirtualIllustration(object):
+    """Virtual illustration based on image file"""
+
+    title = None
+    alt_title = None
+    author = None
+
+    def __init__(self, source):
+        self.source = source
+
+    @property
+    def data(self):
+        return self.source
+
+    def has_data(self):
+        return bool(self.source)