From 671aa67002ff2f109be7947318cbe977e7bb9957 Mon Sep 17 00:00:00 2001 From: alwx Date: Wed, 22 Nov 2023 10:38:14 +0100 Subject: [PATCH] Detect image dimensions correctly --- .../contexts/chat/messages/content/image/view.cljs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/status_im2/contexts/chat/messages/content/image/view.cljs b/src/status_im2/contexts/chat/messages/content/image/view.cljs index b0b3d699af..c2103fd81b 100644 --- a/src/status_im2/contexts/chat/messages/content/image/view.cljs +++ b/src/status_im2/contexts/chat/messages/content/image/view.cljs @@ -8,6 +8,10 @@ [utils.re-frame :as rf] [utils.url :as url])) +;; these constants are used when there is no width or height defined for a specific image +(def ^:const fallback-image-width 1000) +(def ^:const fallback-image-height 1000) + (defn calculate-dimensions [width height max-container-width max-container-height] (let [max-width (if (> width height) max-container-width (* 1.5 constants/image-size)) @@ -15,7 +19,12 @@ {:width (min width max-width) :height (min height max-height)})) (defn image-message - [index {:keys [content image-width image-height message-id] :as message} {:keys [on-long-press]} + [index + {:keys [content image-width image-height message-id] + :as message + :or {image-width fallback-image-width + image-height fallback-image-height}} + {:keys [on-long-press]} message-container-data] (let [insets (safe-area/get-insets) {:keys [window-width padding-left padding-right avatar-container-width