From b8e5901aaf6ad563805ca804df8107b7742cc426 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Tue, 16 Aug 2022 00:32:57 +0000 Subject: [PATCH] Fallback to upload time first --- lib/Db/Util.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Db/Util.php b/lib/Db/Util.php index a434e5d2..1c3c2542 100644 --- a/lib/Db/Util.php +++ b/lib/Db/Util.php @@ -14,7 +14,7 @@ class Util { $this->connection = $connection; } - public static function getDateTaken($file) { + public static function getDateTaken(File $file) { // Attempt to read exif data if (in_array($file->getMimeType(), Application::IMAGE_MIMES)) { $exif = exif_read_data($file->fopen('rb')); @@ -30,6 +30,11 @@ class Util { // Fall back to creation time $dateTaken = $file->getCreationTime(); + // Fall back to upload time + if ($dateTaken == 0) { + $dateTaken = $file->getUploadTime(); + } + // Fall back to modification time if ($dateTaken == 0) { $dateTaken = $file->getMtime();