wiki: Do not try to resize vector images master
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 12 Jun 2020 10:59:38 +0000 (10:59 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 12 Jun 2020 10:59:38 +0000 (10:59 +0000)
This way, we can now support SVG images

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/wiki.py
src/web/wiki.py

index 8237da9..c8a8ff8 100644 (file)
@@ -529,6 +529,12 @@ class File(misc.Object):
        def is_image(self):
                return self.mimetype.startswith("image/")
 
+       def is_vector_image(self):
+               return self.mimetype in ("image/svg+xml",)
+
+       def is_bitmap_image(self):
+               return self.is_image() and not self.is_vector_image()
+
        @lazy_property
        def blob(self):
                res = self.db.get("SELECT data FROM wiki_blobs \
@@ -538,6 +544,8 @@ class File(misc.Object):
                        return bytes(res.data)
 
        def get_thumbnail(self, size):
+               assert self.is_bitmap_image()
+
                cache_key = "-".join((self.path, util.normalize(self.filename), self.created_at.isoformat(), "%spx" % size))
 
                # Try to fetch the data from the cache
index edc5273..c2bdd43 100644 (file)
@@ -245,7 +245,7 @@ class FileHandler(base.BaseHandler):
                size = self.get_argument_int("s", None)
 
                # Check if image should be resized
-               if file.is_image() and size:
+               if size and file.is_bitmap_image():
                        blob = file.get_thumbnail(size)
                else:
                        blob = file.blob