[fractal/fix-image-upload: 2/2] Image: Don't try to load thumbs from non remote paths



commit 61fa72f173abc82cc2b7fa684f383c5f64fbf8a0
Author: Daniel GarcĂ­a Moreno <dani danigm net>
Date:   Thu Jan 9 10:36:43 2020 +0100

    Image: Don't try to load thumbs from non remote paths
    
    Images sent from fractal was using the local path as thumbnail,
    something like /tmp/fractal_RANDOM.png, that's the reason why the image
    thumbs are not shown in the history.
    
    This patch don't try to load thumbnails that are not mxc://,
    http or https and will fallback to the msg full image instead.
    
    Fix https://gitlab.gnome.org/GNOME/fractal/issues/572

 fractal-gtk/src/widgets/message.rs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/fractal-gtk/src/widgets/message.rs b/fractal-gtk/src/widgets/message.rs
index 63c065e6..25404e94 100644
--- a/fractal-gtk/src/widgets/message.rs
+++ b/fractal-gtk/src/widgets/message.rs
@@ -339,8 +339,9 @@ impl MessageBox {
         let bx = gtk::Box::new(gtk::Orientation::Horizontal, 0);
 
         let img_path = match msg.thumb {
-            Some(ref m) => m.clone(),
-            None => msg.url.clone().unwrap_or_default(),
+            // If the thumbnail is not a valid URL we use the msg.url
+            Some(ref m) if m.starts_with("mxc:") || m.starts_with("http") => m.clone(),
+            _ => msg.url.clone().unwrap_or_default(),
         };
         let image = widgets::image::Image::new(&self.backend, self.server_url.clone(), &img_path)
             .size(Some(globals::MAX_IMAGE_SIZE))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]