Skip to content

Commit 671aa67

Browse files
alwxcammellos
authored andcommitted
Detect image dimensions correctly
1 parent dbc8df2 commit 671aa67

File tree

1 file changed

+10
-1
lines changed
  • src/status_im2/contexts/chat/messages/content/image

1 file changed

+10
-1
lines changed

src/status_im2/contexts/chat/messages/content/image/view.cljs

+10-1
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,23 @@
88
[utils.re-frame :as rf]
99
[utils.url :as url]))
1010

11+
;; these constants are used when there is no width or height defined for a specific image
12+
(def ^:const fallback-image-width 1000)
13+
(def ^:const fallback-image-height 1000)
14+
1115
(defn calculate-dimensions
1216
[width height max-container-width max-container-height]
1317
(let [max-width (if (> width height) max-container-width (* 1.5 constants/image-size))
1418
max-height (if (> width height) max-container-height (* 2 constants/image-size))]
1519
{:width (min width max-width) :height (min height max-height)}))
1620

1721
(defn image-message
18-
[index {:keys [content image-width image-height message-id] :as message} {:keys [on-long-press]}
22+
[index
23+
{:keys [content image-width image-height message-id]
24+
:as message
25+
:or {image-width fallback-image-width
26+
image-height fallback-image-height}}
27+
{:keys [on-long-press]}
1928
message-container-data]
2029
(let [insets (safe-area/get-insets)
2130
{:keys [window-width padding-left padding-right avatar-container-width

0 commit comments

Comments
 (0)