diff --git a/src/computersandblues/lodestone/app.cljs b/src/computersandblues/lodestone/app.cljs index 15ba487..af14545 100644 --- a/src/computersandblues/lodestone/app.cljs +++ b/src/computersandblues/lodestone/app.cljs @@ -315,16 +315,23 @@ (drop 1))]) (defn attachment [{:keys [attachment]}] - (case (:type attachment) - "image" [:img {:src (:preview_url attachment) - :alt (:description attachment) - :lazy "lazy"}] - "video" [:video {:controls true} - [:source {:type (str "video/" (last (str/split (:remote_url attachment) #"\."))) - :src (:remote_url attachment)}] - [:a {:href (:remote_url attachment)} (str "Original video at " (:remote_url attachment))]] - [:div [:strong "Unsupported attachment"] - [debug attachment]])) + (let [preview-url (or (:preview_remote_url attachment) (:preview_url attachment)) + remote-url (or (:remote_url attachment) (:url attachment)) + _ (js/console.log :preview-url preview-url :remote_url remote-url :attachment attachment) + ext (last (str/split remote-url #"\."))] + (case (:type attachment) + "image" [:img {:src preview-url + :srcset (str preview-url ", " remote-url) + :alt (:description attachment) + :lazy "lazy"}] + "video" [:video {:controls true} + [:source {:type (str "video/" ext) :src remote-url}] + [:a {:href (:remote_url attachment)} (str "Original video at " (:remote_url attachment))]] + "gifv" [:video {:controls true :loop true :autoplay true} + [:source {:type (str "video/" ext) :src remote-url}] + [:a {:href (:remote_url attachment)} (str "Original video at " (:remote_url attachment))]] + [:div [:strong "Unsupported attachment"] + [debug attachment]]))) (defn post [{:keys [post]}] ; TODO: handle (:sensitive post)