ViewPhoto: prepare meta data in controller; change layout
This commit is contained in:
@@ -37,10 +37,9 @@ class ViewPhoto extends HTMLController
|
||||
{
|
||||
$page = new PhotoPage($this->photo);
|
||||
|
||||
// Exif data?
|
||||
$exif = EXIF::fromFile($this->photo->getFullPath());
|
||||
if ($exif)
|
||||
$page->setExif($exif);
|
||||
// Any (EXIF) meta data?
|
||||
$metaData = $this->prepareMetaData();
|
||||
$page->setMetaData($metaData);
|
||||
|
||||
// What tag are we browsing?
|
||||
$tag = isset($_GET['in']) ? Tag::fromId($_GET['in']) : null;
|
||||
@@ -73,9 +72,43 @@ class ViewPhoto extends HTMLController
|
||||
// ... deleting, that is.
|
||||
else
|
||||
{
|
||||
$photo->unlinkTags([(int) $_POST['id_tag']]);
|
||||
$this->photo->unlinkTags([(int) $_POST['id_tag']]);
|
||||
echo json_encode(['success' => true]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
private function prepareMetaData()
|
||||
{
|
||||
if (!($exif = EXIF::fromFile($this->photo->getFullPath())))
|
||||
throw new UnexpectedValueException('Photo file not found!');
|
||||
|
||||
$metaData = [];
|
||||
|
||||
if (!empty($exif->created_timestamp))
|
||||
$metaData['Date Taken'] = date("j M Y, H:i:s", $exif->created_timestamp);
|
||||
|
||||
if ($author = $this->photo->getAuthor())
|
||||
$metaData['Uploaded by'] = $author->getfullName();
|
||||
|
||||
if (!empty($exif->camera))
|
||||
$metaData['Camera Model'] = $exif->camera;
|
||||
|
||||
if (!empty($exif->shutter_speed))
|
||||
$metaData['Shutter Speed'] = $exif->shutterSpeedFraction();
|
||||
|
||||
if (!empty($exif->aperture))
|
||||
$metaData['Aperture'] = number_format($exif->aperture, 1);
|
||||
|
||||
if (!empty($exif->focal_length))
|
||||
$metaData['Focal Length'] = $exif->focal_length;
|
||||
|
||||
if (!empty($exif->iso))
|
||||
$metaData['ISO Speed'] = $exif->iso;
|
||||
|
||||
if (!empty($exif->software))
|
||||
$metaData['Software'] = $exif->software;
|
||||
|
||||
return $metaData;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user