optimization
[civicrm-core.git] / CRM / Core / BAO / CustomField.php
index 1494bca00586530bd12d1207a199fc7471f59d00..ae9c4023a18b806875c4058d6ceb543267825567 100644 (file)
@@ -1140,11 +1140,11 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
    *
    * @param string|array $value
    * @param array $field
-   * @param int|null $contactID
+   * @param int|null $entityId
    *
    * @return string
    */
-  private static function formatDisplayValue($value, $field, $contactID = NULL) {
+  private static function formatDisplayValue($value, $field, $entityId = NULL) {
 
     if (self::isSerialized($field) && !is_array($value)) {
       $value = CRM_Utils_Array::explodePadded($value);
@@ -1217,16 +1217,18 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
 
       case 'File':
         // In the context of displaying a profile, show file/image
-        if ($contactID && $value) {
-          $url = self::getFileURL($contactID, $field['id'], $value);
-          if ($url) {
-            $display = $url['file_url'];
+        if ($value) {
+          if ($entityId) {
+            $url = self::getFileURL($entityId, $field['id']);
+            if ($url) {
+              $display = $url['file_url'];
+            }
+          }
+          else {
+            // In other contexts show a paperclip icon
+            $icons = CRM_Core_BAO_File::paperIconAttachment('*', $value);
+            $display = $icons[$value];
           }
-        }
-        // In other contexts show a paperclip icon
-        elseif ($value) {
-          $icons = CRM_Core_BAO_File::paperIconAttachment('*', $value);
-          $display = $icons[$value];
         }
         break;