|
1 | 1 | <?php |
2 | 2 |
|
3 | 3 | /* |
4 | | - * Copyright (c) 2011-2023 Mark C. Prins <[email protected]> |
| 4 | + * Copyright (c) 2011-2024 Mark C. Prins <[email protected]> |
5 | 5 | * |
6 | 6 | * Permission to use, copy, modify, and distribute this software for any |
7 | 7 | * purpose with or without fee is hereby granted, provided that the above |
@@ -86,10 +86,10 @@ final public function generateSpatialIndex(): bool |
86 | 86 | } |
87 | 87 | // media |
88 | 88 | $media = []; |
89 | | - search($media, $conf ['mediadir'], 'search_media', []); |
| 89 | + search($media, $conf['mediadir'], 'search_media', []); |
90 | 90 | foreach ($media as $medium) { |
91 | | - if ($medium ['isimg']) { |
92 | | - $this->indexImage($medium); |
| 91 | + if ($medium['isimg']) { |
| 92 | + $this->indexImage($medium['id']); |
93 | 93 | } |
94 | 94 | } |
95 | 95 | return true; |
@@ -200,33 +200,34 @@ private function saveIndex(): bool |
200 | 200 | /** |
201 | 201 | * Add an index entry for this file having EXIF / IPTC data. |
202 | 202 | * |
203 | | - * @param $img |
204 | | - * a Dokuwiki image |
205 | | - * @return bool true when image was succesfully added to the index. |
| 203 | + * @param $imgId |
| 204 | + * a Dokuwiki image id |
| 205 | + * @return bool true when image was successfully added to the index. |
206 | 206 | * @throws Exception |
207 | 207 | * @see http://www.php.net/manual/en/function.iptcparse.php |
208 | 208 | * @see http://php.net/manual/en/function.exif-read-data.php |
209 | 209 | * |
210 | 210 | */ |
211 | | - final public function indexImage(array $img): bool |
| 211 | + final public function indexImage(string $imgId): bool |
212 | 212 | { |
213 | 213 | // test for supported files (jpeg only) |
214 | 214 | if ( |
215 | | - (!str_ends_with($img ['file'], '.jpg')) && |
216 | | - (!str_ends_with($img ['file'], '.jpeg')) |
| 215 | + (!str_ends_with(strtolower($imgId), '.jpg')) && |
| 216 | + (!str_ends_with(strtolower($imgId), '.jpeg')) |
217 | 217 | ) { |
| 218 | + Logger::debug("indexImage:: " . $imgId . " is not a supported image file."); |
218 | 219 | return false; |
219 | 220 | } |
220 | 221 |
|
221 | | - $geometry = $this->getCoordsFromExif($img ['id']); |
| 222 | + $geometry = $this->getCoordsFromExif($imgId); |
222 | 223 | if (!$geometry) { |
223 | 224 | return false; |
224 | 225 | } |
225 | 226 | $geohash = $geometry->out('geohash'); |
226 | 227 | // TODO truncate the geohash to something reasonable, otherwise they are |
227 | | - // useless as an indexing mechanism eg. u1h73weckdrmskdqec3c9 is far too |
228 | | - // precise, limit at ~9 as most GPS are not submeter accurate |
229 | | - return $this->addToIndex($geohash, 'media__' . $img ['id']); |
| 228 | + // useless as an indexing mechanism eg. u1h73weckdrmskdqec3c9 is far too |
| 229 | + // precise, limit at ~9 as most GPS are not submeter accurate |
| 230 | + return $this->addToIndex($geohash, 'media__' . $imgId); |
230 | 231 | } |
231 | 232 |
|
232 | 233 | /** |
|
0 commit comments