diff --git a/cps/static/js/kthoom.js b/cps/static/js/kthoom.js index 40db69ab..69f4be96 100644 --- a/cps/static/js/kthoom.js +++ b/cps/static/js/kthoom.js @@ -141,9 +141,24 @@ var createURLFromArray = function(array, mimeType) { kthoom.ImageFile = function(file) { this.filename = file.filename; var fileExtension = file.filename.split(".").pop().toLowerCase(); - this.mimeType = fileExtension === "png" ? "image/png" : - (fileExtension === "jpg" || fileExtension === "jpeg") ? "image/jpeg" : - fileExtension === "gif" ? "image/gif" : fileExtension === "svg" ? "image/xml+svg" : undefined; + switch (fileExtension) { + case "jpg": + case "jpeg": + this.mimeType = "image/jpeg"; + break; + case "gif": + this.mimeType = "iamge/gif"; + break; + case "svg": + this.mimeType = "image/svg+xml"; + break; + case "webp": + this.mimeType = "image/webp"; + break; + default: + this.mimeType = undefined; + break; + } if ( this.mimeType !== undefined) { this.dataURI = createURLFromArray(file.fileData, this.mimeType); this.data = file; @@ -331,7 +346,7 @@ function setImage(url) { $("#mainText").innerHTML(""); }; xhr.send(null); - } else if (!/(jpg|jpeg|png|gif)$/.test(imageFiles[currentImage].filename) && imageFiles[currentImage].data.uncompressedSize < 10 * 1024) { + } else if (!/(jpg|jpeg|png|gif|webp)$/.test(imageFiles[currentImage].filename) && imageFiles[currentImage].data.uncompressedSize < 10 * 1024) { xhr.open("GET", url, true); xhr.onload = function() { $("#mainText").css("display", ""); diff --git a/cps/web.py b/cps/web.py index 2a027eac..5b805ac8 100644 --- a/cps/web.py +++ b/cps/web.py @@ -264,7 +264,7 @@ def get_comic_book(book_id, book_format, page): else: b64 = extract(page).encode('base64') ext = names[page].rpartition('.')[-1] - if ext not in ('png', 'gif', 'jpg', 'jpeg'): + if ext not in ('png', 'gif', 'jpg', 'jpeg', 'webp'): ext = 'png' extractedfile="data:image/" + ext + ";base64," + b64 fileData={"name": names[page], "page":page, "last":len(names)-1, "content": extractedfile}