From ccf2c8819cafe948354dab44cceba53e396a2b1a Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 11 Nov 2021 10:49:20 +1300 Subject: [PATCH] Ensure imageUrl is always set --- CRM/Contact/Form/Contact.php | 4 +--- CRM/Contact/Page/View.php | 5 ++--- templates/CRM/Contact/Page/View/Summary-tab.tpl | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CRM/Contact/Form/Contact.php b/CRM/Contact/Form/Contact.php index 2e6b51d888..4740077f3d 100644 --- a/CRM/Contact/Form/Contact.php +++ b/CRM/Contact/Form/Contact.php @@ -426,9 +426,7 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { //set address block defaults CRM_Contact_Form_Edit_Address::setDefaultValues($defaults, $this); - if (!empty($defaults['image_URL'])) { - $this->assign("imageURL", CRM_Utils_File::getImageURL($defaults['image_URL'])); - } + $this->assign('imageURL', !empty($defaults['image_URL']) ? CRM_Utils_File::getImageURL($defaults['image_URL']) : ''); //set location type and country to default for each block $this->blockSetDefaults($defaults); diff --git a/CRM/Contact/Page/View.php b/CRM/Contact/Page/View.php index bd7d327bc2..96dbb6bd7d 100644 --- a/CRM/Contact/Page/View.php +++ b/CRM/Contact/Page/View.php @@ -143,9 +143,8 @@ class CRM_Contact_Page_View extends CRM_Core_Page { $path = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId); CRM_Utils_System::appendBreadCrumb([['title' => ts('View Contact'), 'url' => $path]]); - if ($image_URL = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'image_URL')) { - $this->assign("imageURL", CRM_Utils_File::getImageURL($image_URL)); - } + $image_URL = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'image_URL'); + $this->assign('imageURL', $image_URL ? CRM_Utils_File::getImageURL($image_URL) : ''); // also store in session for future use $session = CRM_Core_Session::singleton(); diff --git a/templates/CRM/Contact/Page/View/Summary-tab.tpl b/templates/CRM/Contact/Page/View/Summary-tab.tpl index 60af440b0a..74410b2534 100644 --- a/templates/CRM/Contact/Page/View/Summary-tab.tpl +++ b/templates/CRM/Contact/Page/View/Summary-tab.tpl @@ -27,12 +27,12 @@
{crmRegion name="contact-basic-info-right"} - {if !empty($imageURL)} + {if $imageURL}
{include file="CRM/Contact/Page/ContactImage.tpl"}
{/if} -
+
{include file="CRM/Contact/Page/Inline/Basic.tpl"}
-- 2.25.1