From 88e1ade2e60fb93683b6dd0451ea5a93071b6b74 Mon Sep 17 00:00:00 2001
From: Uma <uma.s@vtiger.com>
Date: Tue, 12 Nov 2019 16:58:41 +0530
Subject: [PATCH] Fixes #1202 image url only on existence

---
 modules/Users/models/Record.php  | 5 ++++-
 modules/Vtiger/models/Record.php | 7 +++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/modules/Users/models/Record.php b/modules/Users/models/Record.php
index 56cfb7a67..b2996ec79 100644
--- a/modules/Users/models/Record.php
+++ b/modules/Users/models/Record.php
@@ -399,13 +399,16 @@ class Users_Record_Model extends Vtiger_Record_Model {
 
 			//decode_html - added to handle UTF-8 characters in file names
 			$imageOriginalName = urlencode(decode_html($imageName));
+            if($url) {
+                $url = $site_URL.$url;
+            }
 
 			$imageDetails[] = array(
 					'id' => $imageId,
 					'orgname' => $imageOriginalName,
 					'path' => $imagePath.$imageId,
 					'name' => $imageName,
-                    'url'  => $site_URL.$url
+                    'url'  => $url
 			);
 		}
 		return $imageDetails;
diff --git a/modules/Vtiger/models/Record.php b/modules/Vtiger/models/Record.php
index c6d9a683f..f67c7b1b1 100644
--- a/modules/Vtiger/models/Record.php
+++ b/modules/Vtiger/models/Record.php
@@ -416,14 +416,17 @@ class Vtiger_Record_Model extends Vtiger_Base_Model {
             $url = \Vtiger_Functions::getFilePublicURL($imageId, $imageName);
 			//decode_html - added to handle UTF-8 characters in file names
 			$imageOriginalName = urlencode(decode_html($imageName));
-
+            if($url) {
+                $url = $site_URL.$url;
+            }
+            
 			if(!empty($imageName)){
 				$imageDetails[] = array(
 						'id' => $imageId,
 						'orgname' => $imageOriginalName,
 						'path' => $imagePath.$imageId,
 						'name' => $imageName,
-                        'url'  => $site_URL.$url
+                        'url'  => $url
 				);
 			}
 		}
-- 
GitLab