Add support for gifs
This commit is contained in:
parent
2b78afde38
commit
c91b1ff2d4
1 changed files with 17 additions and 10 deletions
|
|
@ -315,16 +315,23 @@
|
||||||
(drop 1))])
|
(drop 1))])
|
||||||
|
|
||||||
(defn attachment [{:keys [attachment]}]
|
(defn attachment [{:keys [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)
|
(case (:type attachment)
|
||||||
"image" [:img {:src (:preview_url attachment)
|
"image" [:img {:src preview-url
|
||||||
|
:srcset (str preview-url ", " remote-url)
|
||||||
:alt (:description attachment)
|
:alt (:description attachment)
|
||||||
:lazy "lazy"}]
|
:lazy "lazy"}]
|
||||||
"video" [:video {:controls true}
|
"video" [:video {:controls true}
|
||||||
[:source {:type (str "video/" (last (str/split (:remote_url attachment) #"\.")))
|
[:source {:type (str "video/" ext) :src remote-url}]
|
||||||
:src (:remote_url attachment)}]
|
[: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))]]
|
[:a {:href (:remote_url attachment)} (str "Original video at " (:remote_url attachment))]]
|
||||||
[:div [:strong "Unsupported attachment"]
|
[:div [:strong "Unsupported attachment"]
|
||||||
[debug attachment]]))
|
[debug attachment]])))
|
||||||
|
|
||||||
(defn post [{:keys [post]}]
|
(defn post [{:keys [post]}]
|
||||||
; TODO: handle (:sensitive post)
|
; TODO: handle (:sensitive post)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue