Fallback to upload time first

pull/37/head
Varun Patil 2022-08-16 00:32:57 +00:00
parent 56fee51f1c
commit b8e5901aaf
1 changed files with 6 additions and 1 deletions

View File

@ -14,7 +14,7 @@ class Util {
$this->connection = $connection; $this->connection = $connection;
} }
public static function getDateTaken($file) { public static function getDateTaken(File $file) {
// Attempt to read exif data // Attempt to read exif data
if (in_array($file->getMimeType(), Application::IMAGE_MIMES)) { if (in_array($file->getMimeType(), Application::IMAGE_MIMES)) {
$exif = exif_read_data($file->fopen('rb')); $exif = exif_read_data($file->fopen('rb'));
@ -30,6 +30,11 @@ class Util {
// Fall back to creation time // Fall back to creation time
$dateTaken = $file->getCreationTime(); $dateTaken = $file->getCreationTime();
// Fall back to upload time
if ($dateTaken == 0) {
$dateTaken = $file->getUploadTime();
}
// Fall back to modification time // Fall back to modification time
if ($dateTaken == 0) { if ($dateTaken == 0) {
$dateTaken = $file->getMtime(); $dateTaken = $file->getMtime();