]> git.ipfire.org Git - ipfire.org.git/commitdiff
wiki: Do not try to resize vector images
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 8237da97ef6e5a18a9c8b20715bcf71a9da39e58..c8a8ff8d44a8fffa045ed71bfcb62f8032f95fc0 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 edc52730ce62e1d92c1ff983b10d99099796c3c9..c2bdd43f334653230c756496c88fbc2f197c1abc 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