From d42c3c142cda217f9fe34ecb3116b94cf2ceae09 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Sat, 2 Dec 2023 00:50:04 +0100 Subject: [PATCH] PhotosIndex: differentiate dual/single layouts by landscape/portrait --- models/PhotoMosaic.php | 18 ++++---- templates/PhotosIndex.php | 88 ++++++++++++++++++++++----------------- 2 files changed, 61 insertions(+), 45 deletions(-) diff --git a/models/PhotoMosaic.php b/models/PhotoMosaic.php index 8fc0eef..3f75407 100644 --- a/models/PhotoMosaic.php +++ b/models/PhotoMosaic.php @@ -33,17 +33,21 @@ class PhotoMosaic 'panorama' => [Image::TYPE_PANORAMA], // Big-small juxtapositions - 'portrait' => [Image::TYPE_PORTRAIT, Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE, - Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE], - 'landscape' => [Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE], + 'sidePortrait' => [Image::TYPE_PORTRAIT, Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE, + Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE], + 'sideLandscape' => [Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE], // Single row of three - 'landscapes' => [Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE], - 'portraits' => [Image::TYPE_PORTRAIT, Image::TYPE_PORTRAIT, Image::TYPE_PORTRAIT], + 'threeLandscapes' => [Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE], + 'threePortraits' => [Image::TYPE_PORTRAIT, Image::TYPE_PORTRAIT, Image::TYPE_PORTRAIT], + + // Dual layouts + 'dualLandscapes' => [Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE], + 'dualPortraits' => [Image::TYPE_PORTRAIT, Image::TYPE_PORTRAIT], // Fallback layouts - 'duo' => [Image::TYPE_LANDSCAPE, Image::TYPE_LANDSCAPE], - 'single' => [Image::TYPE_LANDSCAPE | Image::TYPE_PORTRAIT], + 'singleLandscape' => [Image::TYPE_LANDSCAPE], + 'singlePortrait' => [Image::TYPE_PORTRAIT], ]; return $layouts; diff --git a/templates/PhotosIndex.php b/templates/PhotosIndex.php index adef18d..537078b 100644 --- a/templates/PhotosIndex.php +++ b/templates/PhotosIndex.php @@ -137,7 +137,7 @@ class PhotosIndex extends Template } } - protected function portrait(array $photos, $altLayout) + protected function sidePortrait(array $photos, $altLayout) { $image = array_shift($photos); @@ -170,7 +170,7 @@ class PhotosIndex extends Template '; } - protected function landscape(array $photos, $altLayout) + protected function sideLandscape(array $photos, $altLayout) { $image = array_shift($photos); @@ -203,41 +203,7 @@ class PhotosIndex extends Template '; } - protected function duo(array $photos, $altLayout) - { - echo ' -
'; - - foreach ($photos as $image) - { - echo ' -
'; - - $this->photo($image, 'duo', static::DUO_WIDTH, static::DUO_HEIGHT, true); - - echo ' -
'; - } - - echo ' -
'; - } - - protected function single(array $photos, $altLayout) - { - echo ' -
-
'; - - $image = array_shift($photos); - $this->photo($image, 'single', static::SINGLE_WIDTH, static::SINGLE_HEIGHT, 'top'); - - echo ' -
-
'; - } - - protected function landscapes(array $photos, $altLayout) + protected function threeLandscapes(array $photos, $altLayout) { echo '
'; @@ -257,7 +223,7 @@ class PhotosIndex extends Template
'; } - protected function portraits(array $photos, $altLayout) + protected function threePortraits(array $photos, $altLayout) { echo '
'; @@ -277,6 +243,52 @@ class PhotosIndex extends Template
'; } + protected function dualLandscapes(array $photos, $altLayout) + { + echo ' +
'; + + foreach ($photos as $image) + { + echo ' +
'; + + $this->photo($image, 'duo', static::DUO_WIDTH, static::DUO_HEIGHT, true); + + echo ' +
'; + } + + echo ' +
'; + } + + protected function dualPortraits(array $photos, $altLayout) + { + // Recycle the row layout so portraits don't appear too large + $this->threePortraits($photos, $altLayout); + } + + protected function singleLandscape(array $photos, $altLayout) + { + echo ' +
+
'; + + $image = array_shift($photos); + $this->photo($image, 'single', static::SINGLE_WIDTH, static::SINGLE_HEIGHT, 'top'); + + echo ' +
+
'; + } + + protected function singlePortrait(array $photos, $altLayout) + { + // Recycle the row layout so portraits don't appear too large + $this->threePortraits($photos, $altLayout); + } + public function setUrlSuffix($suffix) { $this->url_suffix = $suffix;