Переглянути джерело

Added auto base64 type detection in thumbnail loading

tobychui 4 роки тому
батько
коміт
f83fd15763
1 змінених файлів з 13 додано та 1 видалено
  1. 13 1
      web/SystemAO/file_system/file_explorer.html

+ 13 - 1
web/SystemAO/file_system/file_explorer.html

@@ -1877,8 +1877,20 @@
                         var thumbData = JSON.parse(event.data);
                         $(".fileObject").each(function(){
                             if (thumbData[1].length > 0){
+                                //Extract image type from base64
+                                let tid = thumbData[1].charAt(0);
+                                let ext = "jpg";
+                                if (tid == "i"){
+                                    ext = "png";
+                                }else if (tid == "R"){
+                                    ext = "gif";
+                                }else if (tid == "U"){
+                                    ext = "webp";
+                                }
+
+                                //Put the image data to image element
                                 if ($(this).attr("filename") == thumbData[0]){
-                                    $(this).find("img").attr("src","data:image/jpg;base64," + thumbData[1]);
+                                    $(this).find("img").attr("src","data:image/" + ext + ";base64," + thumbData[1]);
                                 }
                             }