From 927ee695030be8c41caf773e5a89bcb51dd434d4 Mon Sep 17 00:00:00 2001 From: Julian Egelstaff Date: Thu, 19 Dec 2024 14:57:29 -0500 Subject: [PATCH] Adding displayFileImageLink function --- modules/formulize/class/fileUploadElement.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/formulize/class/fileUploadElement.php b/modules/formulize/class/fileUploadElement.php index 3e9d2303c..d5ad4555c 100644 --- a/modules/formulize/class/fileUploadElement.php +++ b/modules/formulize/class/fileUploadElement.php @@ -576,6 +576,24 @@ function displayFileImage($entryOrDataset, $elementHandle, $dataSetKey=null, $lo return $url; } +/** + * Take the value of a file upload element, and return an anchor tag of the image thumbnail if applicable + * + * @param array $entryOrDataset The record from a dataset, or the entire dataset, as returned from getData + * @param string $elementHandle The element handle of the file upload element we're working with + * @param int $dataSetKey Optional. The key in the dataset array of the entry record we want to work with. Required if $entryOrDataset is the entire dataset. + * @param int $localId Optional. The ordinal id of the instance of the element handle we want to work with. Only required if there are multiple entries represented in this dataset record which all include data attached to this element handle, ie: if the handle is on the many side of a one to many connection in the dataset. + * @return string Returns the an HTML a tag referring to the file if the file is an image, and using the thumbnail as the clickable element, or returns the url for the file otherwise. If the file upload failed, this will return the error message from when the upload failed. + */ +function displayFileImageLink($entryOrDataset, $elementHandle, $dataSetKey=null, $localId='NULL') { + $image = displayFileImage($entryOrDataset, $elementHandle, $dataSetKey=null, $localId='NULL'); + if(substr($image, 0, 4) == '