Image fetch and resize working.

This commit is contained in:
Kim Taylor
2024-09-23 23:25:12 +10:00
parent f9c151bfae
commit c27cc2831b
3 changed files with 54 additions and 12 deletions

View File

@@ -61,7 +61,9 @@ foreach ($lga_list as $lga) {
if (count($lga_candidates) === 0) continue;
$output_file = dirname($lga['config-file'])."/candidates-generic.csv";
$dir = dirname($lga['config-file']);
$dir_files = scandir($dir);
$output_file = $dir."/candidates-generic.csv";
if (($handle = fopen($output_file, "w")) === FALSE) {
error_log('Error opening output file');
@@ -74,10 +76,18 @@ foreach ($lga_list as $lga) {
}
foreach ($lga_candidates as $candidate) {
/* Add extension to photo hash */
foreach ($dir_files as $file) {
if (strstr($file, $candidate['Photo'])) {
$candidate['Photo'] = $file;
}
}
$fields = [
$candidate['match_ward'],
$candidate['Name'],
$candidate['Score'],
$candidate['Pledge'],
$candidate['Photo'],
];

View File

@@ -20,8 +20,8 @@ function parse_generic_csv($generic_csv) {
if (strstr($value, "Political Party")) $value = "Party";
if ($value === "Pledge") {
if (strstr($data[$key], "I pledge")) $data[$key] = "Yes";
else $data[$key] = "No";
if (strstr($data[$key], "I pledge")) $data[$key] = "y";
else $data[$key] = "n";
}
if ($value === "Photo") {