From e6e9f7623066a372d2747e8d404d651da2abe3b9 Mon Sep 17 00:00:00 2001
From: lizandrogd <77708265+lizandrogd@users.noreply.github.com>
Date: Wed, 21 Jan 2026 12:44:12 -0500
Subject: [PATCH] Update chat_window.php
---
chat_window.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 46 insertions(+), 2 deletions(-)
diff --git a/chat_window.php b/chat_window.php
index 257d09a..02ab464 100644
--- a/chat_window.php
+++ b/chat_window.php
@@ -589,7 +589,39 @@ if (empty($user_id)) {
// Mensaje multimedia
switch (msg.message_type) {
case 'image':
- contentHtml = `
`;
+ // Determinar miniatura y URL completa (soporte para local, api/get_media?id= y URLs directas)
+ let thumbUrl = '';
+ if (msg.local_thumb) {
+ thumbUrl = `/${msg.local_thumb}`;
+ } else if (msg.local_file) {
+ thumbUrl = `/${msg.local_file}`;
+ } else if (msg.media_url) {
+ thumbUrl = msg.media_url;
+ } else if (msg.media_url_external) {
+ thumbUrl = msg.media_url_external; // se intentará redirigir/proxear al abrir
+ }
+
+ let fullUrl = '';
+ if (msg.local_file) {
+ fullUrl = `/api/version/media-url.php?local=${encodeURIComponent(msg.local_file)}`;
+ } else if (msg.media_url_external) {
+ if (msg.media_url_external.indexOf('api/get_media.php?id=') !== -1) {
+ const parts = msg.media_url_external.split('id=');
+ const mid = parts[1] ? decodeURIComponent(parts[1]) : '';
+ fullUrl = `/api/version/media-url.php?id=${encodeURIComponent(mid)}`;
+ } else if (/^https?:\/\//i.test(msg.media_url_external)) {
+ fullUrl = `/api/version/media-url.php?url=${encodeURIComponent(msg.media_url_external)}`;
+ } else {
+ fullUrl = `/api/version/media-url.php?url=${encodeURIComponent(msg.media_url_external)}`;
+ }
+ } else {
+ fullUrl = msg.media_url || thumbUrl || '';
+ }
+
+ contentHtml = `
+
+
+ `;
break;
case 'video':
contentHtml = `