write: check array keys for exif filter (fix #381)
parent
25318b9402
commit
d6fba7e4a9
|
@ -129,20 +129,21 @@ class TimelineWrite
|
|||
}
|
||||
|
||||
// Clean up EXIF to keep only useful metadata
|
||||
foreach ($exif as $key => &$value) {
|
||||
$filteredExif = [];
|
||||
foreach ($exif as $key => $value) {
|
||||
// Truncate any fields > 2048 chars
|
||||
if (\is_string($value) && \strlen($value) > 2048) {
|
||||
$exif[$key] = substr($value, 0, 2048);
|
||||
$value = substr($value, 0, 2048);
|
||||
}
|
||||
|
||||
// These are huge and not needed
|
||||
if (!EXIF_FIELDS_LIST[$key] ?? false) {
|
||||
unset($exif[$key]);
|
||||
// Only keep fields in the whitelist
|
||||
if (\array_key_exists($key, EXIF_FIELDS_LIST)) {
|
||||
$filteredExif[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Store JSON string
|
||||
$exifJson = json_encode($exif);
|
||||
$exifJson = json_encode($filteredExif);
|
||||
|
||||
// Store error if data > 64kb
|
||||
if (\is_string($exifJson)) {
|
||||
|
|
Loading…
Reference in New Issue