From 6a17fd37162d3b0ead16383cd0f1ca6da01165d7 Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 15 Nov 2019 23:39:20 +1100 Subject: [PATCH] Fix for photos with no exif:DateTime --- app/Models/Photo.php | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/app/Models/Photo.php b/app/Models/Photo.php index 5169f18..840c1f6 100644 --- a/app/Models/Photo.php +++ b/app/Models/Photo.php @@ -140,11 +140,22 @@ class Photo extends Abstracted\Catalog switch ($property) { - case 'creationdate': return strtotime($this->property('exif:DateTimeOriginal') ? $this->property('exif:DateTimeOriginal') : $this->property('exif:DateTime')); break; - case 'height': return $this->_o->getImageHeight(); break; - case 'orientation': return $this->_o->getImageOrientation(); break; - case 'signature': return $this->_o->getImageSignature(); break; - case 'width': return $this->_o->getImageWidth(); break; + case 'creationdate': + if ($this->property('exif:DateTimeOriginal') == '0000:00:00 00:00:00' + && $this->property('exif:DateTimeOriginal') == '0000:00:00 00:00:00') + return NULL; + + return strtotime( + $this->property('exif:DateTimeOriginal') && $this->property('exif:DateTimeOriginal') != '0000:00:00 00:00:00' + ? $this->property('exif:DateTimeOriginal') + : $this->property('exif:DateTime')); + break; + + case 'height': return $this->_o->getImageHeight(); + case 'orientation': return $this->_o->getImageOrientation(); + case 'signature': return $this->_o->getImageSignature(); + case 'width': return $this->_o->getImageWidth(); + default: return $this->_o->getImageProperty($property); } @@ -157,8 +168,7 @@ class Photo extends Abstracted\Catalog public function setDateCreated() { - if ($this->property('creationdate')) - $this->date_created = $this->property('creationdate'); + $this->date_created = $this->property('creationdate'); } public function setLocation()