From 8b2e66b044f29a36b68a25f997c4e3c23e7f0158 Mon Sep 17 00:00:00 2001 From: Kim Taylor Date: Tue, 24 Sep 2024 15:10:31 +1000 Subject: [PATCH] Don't try to match photos if the field is empty. --- csv-generic/gen-generic.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/csv-generic/gen-generic.php b/csv-generic/gen-generic.php index 58295d1..2a961b9 100644 --- a/csv-generic/gen-generic.php +++ b/csv-generic/gen-generic.php @@ -77,10 +77,12 @@ foreach ($lga_list as $lga) { foreach ($lga_candidates as $candidate) { /* Add extension to photo hash */ - foreach ($dir_files as $file) { - if (preg_match("/\.json$/", $file)) continue; - if (strstr($file, $candidate['Photo'])) { - $candidate['Photo'] = $file; + if (strlen($candidate['Photo'])) { + foreach ($dir_files as $file) { + if (preg_match("/\.json$/", $file)) continue; + if (strstr($file, $candidate['Photo'])) { + $candidate['Photo'] = $file; + } } }