فهرست منبع

fix: catch error when rendering image with wrong metadata

Tienson Qin 4 سال پیش
والد
کامیت
21d9728f2f
1فایلهای تغییر یافته به همراه15 افزوده شده و 13 حذف شده
  1. 15 13
      src/main/frontend/components/block.cljs

+ 15 - 13
src/main/frontend/components/block.cljs

@@ -239,19 +239,21 @@
                    nil
                    (safe-read-string metadata false))
         title (second (first label))]
-    (if (and (config/local-asset? href)
-             (config/local-db? (state/get-current-repo)))
-      (asset-link config title href label metadata full_text)
-      (let [href (cond
-                   (util/starts-with? href "http")
-                   href
-
-                   config/publishing?
-                   (subs href 1)
-
-                   :else
-                   (get-file-absolute-path config href))]
-        (resizable-image config title href metadata full_text false)))))
+    (ui/catch-error
+     [:span.warning full_text]
+     (if (and (config/local-asset? href)
+              (config/local-db? (state/get-current-repo)))
+       (asset-link config title href label metadata full_text)
+       (let [href (cond
+                    (util/starts-with? href "http")
+                    href
+
+                    config/publishing?
+                    (subs href 1)
+
+                    :else
+                    (get-file-absolute-path config href))]
+         (resizable-image config title href metadata full_text false))))))
 
 (defn repetition-to-string
   [[[kind] [duration] n]]