From 691a4a88e6ffc88b46a1d4da267cadba6de93296 Mon Sep 17 00:00:00 2001 From: OzzieIsaacs Date: Sat, 31 Mar 2018 17:05:15 +0200 Subject: [PATCH] Added support for svg in comics (not working in IE11) --- cps/static/js/kthoom.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cps/static/js/kthoom.js b/cps/static/js/kthoom.js index 17ee8097..16c51cdd 100644 --- a/cps/static/js/kthoom.js +++ b/cps/static/js/kthoom.js @@ -96,6 +96,11 @@ var createURLFromArray = function(array, mimeType) { var url; var blob; + if (mimeType === 'image/xml+svg') { + const xmlStr = new TextDecoder('utf-8').decode(array); + return 'data:image/svg+xml;UTF-8,' + encodeURIComponent(xmlStr); + } + // TODO: Move all this browser support testing to a common place // and do it just once. @@ -130,7 +135,7 @@ kthoom.ImageFile = function(file) { var fileExtension = file.filename.split(".").pop().toLowerCase(); var mimeType = fileExtension === "png" ? "image/png" : (fileExtension === "jpg" || fileExtension === "jpeg") ? "image/jpeg" : - fileExtension === "gif" ? "image/gif" : null; + fileExtension === "gif" ? "image/gif" : fileExtension == 'svg' ? 'image/xml+svg' : undefined; this.dataURI = createURLFromArray(file.fileData, mimeType); this.data = file; };