From d3c2a1c18b6cab1fdcc84ce2f1c848d8778e41a0 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Wed, 6 Jan 2016 03:04:03 +0530 Subject: [PATCH] CRM-17770 fix - Custom contact fields with files prevent contact record from loading https://issues.civicrm.org/jira/browse/CRM-17770 --- CRM/Core/BAO/CustomField.php | 14 +++++++++++--- .../CRM/Contact/Page/View/CustomDataFieldView.tpl | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index 1494bca005..6839004327 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -1223,10 +1223,18 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { $display = $url['file_url']; } } - // In other contexts show a paperclip icon elseif ($value) { - $icons = CRM_Core_BAO_File::paperIconAttachment('*', $value); - $display = $icons[$value]; + // In the context of inline view, show file/image + if (is_string($value)) { + $fileId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_File', $value, 'id', 'uri'); + $results = CRM_Core_BAO_File::getEntityFile('*', $fileId); + $display = $results[$fileId]; + } + // In other contexts show a paperclip icon + else { + $icons = CRM_Core_BAO_File::paperIconAttachment('*', $value); + $display = $icons[$value]; + } } break; diff --git a/templates/CRM/Contact/Page/View/CustomDataFieldView.tpl b/templates/CRM/Contact/Page/View/CustomDataFieldView.tpl index d7be1a0400..797f745601 100644 --- a/templates/CRM/Contact/Page/View/CustomDataFieldView.tpl +++ b/templates/CRM/Contact/Page/View/CustomDataFieldView.tpl @@ -43,7 +43,7 @@ {else}
{$element.field_title}
- {if $element.field_type == 'File'} + {if $element.field_type == 'File' && !empty($element.field_value)} {if $element.field_value.displayURL}
-- 2.25.1