Skip to content

Commit

Permalink
Refactor thumbor URL to fix compatibility with thumbor 7.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankApiyo committed Sep 19, 2023
1 parent 34254e5 commit 8f1b74a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/milia/utils/images.cljc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns milia.utils.images
(:require [chimera.urls :refer [url]]
[clojure.string :refer [starts-with?]]
[milia.utils.remote :refer [thumbor-server]]))

(defn resize-image
Expand All @@ -9,6 +10,11 @@
([image-url width-px height-px]
(resize-image image-url width-px height-px thumbor-server))
([image-url width-px height-px image-server-url]
(str image-server-url
(url "unsafe"
(str width-px "x" height-px) "smart" image-url))))
(let [thumbor-server-prefix (str thumbor-server "/image/")]
(str image-server-url
(url
"unsafe"
(str width-px "x" height-px) "smart"
(if (starts-with? image-server-url (str thumbor-server "/image/"))
(subs image-url (count thumbor-server-prefix))
image-url))))))

0 comments on commit 8f1b74a

Please sign in to comment.