From 2631d5c3a270f35ae9919be4f4e1302e4d1187ce Mon Sep 17 00:00:00 2001
From: SpiritCroc <dev@spiritcroc.de>
Date: Thu, 16 Jun 2022 12:37:42 +0200
Subject: [PATCH] Fix crash for huge inline pictures

Change-Id: I9968e7fd95aa11d524a57c2186d518262fed5aa0
---
 .../main/java/im/vector/app/features/html/EventHtmlRenderer.kt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/vector/src/main/java/im/vector/app/features/html/EventHtmlRenderer.kt b/vector/src/main/java/im/vector/app/features/html/EventHtmlRenderer.kt
index 8f3f5ce600..f19437af69 100644
--- a/vector/src/main/java/im/vector/app/features/html/EventHtmlRenderer.kt
+++ b/vector/src/main/java/im/vector/app/features/html/EventHtmlRenderer.kt
@@ -98,7 +98,8 @@ class EventHtmlRenderer @Inject constructor(
                             if (url.isMxcUrl()) {
                                 val contentUrlResolver = activeSessionHolder.getActiveSession().contentUrlResolver()
                                 val imageUrl = contentUrlResolver.resolveFullSize(url)
-                                return Glide.with(context).load(imageUrl)
+                                // Override size to avoid crashes for huge pictures
+                                return Glide.with(context).load(imageUrl).override(500)
                             }
                             // We don't want to support other url schemes here, so just return a request for null
                             return Glide.with(context).load(null as String?)