Use default image for candidates who have signed the ledge, but not provided an image.

This commit is contained in:
Kim Taylor
2024-09-25 14:38:13 +10:00
parent 620d1bf06d
commit 8543bc1c53
3 changed files with 30 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
<?php
function parse_pledge_data($candidates_files) {
function parse_pledge_data($candidates_files, $default_image) {
$candidate_data = [];
foreach ($candidates_files as $key => $file) {
$config_file = dirname($file)."/config.json";
@@ -19,8 +19,13 @@ function parse_pledge_data($candidates_files) {
$candidate = [];
$candidate['Pledge'] = 'n';
$candidate['Picture'] = "";
$candidate['image_url'] = "";
$candidate['image_id'] = "";
if (is_array($default_image)) {
$candidate['image_url'] = $default_image['url'];
$candidate['image_id'] = $default_image['id'];
} else {
$candidate['image_url'] = "";
$candidate['image_id'] = "";
}
foreach ($headers as $key => $value) {
$candidate[$value] = $data[$key];
}