diff --git a/models/PhotoMosaic.php b/models/PhotoMosaic.php index db86be7..901e8a0 100644 --- a/models/PhotoMosaic.php +++ b/models/PhotoMosaic.php @@ -165,7 +165,10 @@ class PhotoMosaic return [$photos, 'single']; } - // A boring set it is, then. - return [$photos, 'row']; + // Last resort: majority vote + if ($num_portrait > $num_landscape) + return [$photos, 'portraits']; + else + return [$photos, 'landscapes']; } } diff --git a/public/css/admin.css b/public/css/admin.css index 92c2736..6be934e 100644 --- a/public/css/admin.css +++ b/public/css/admin.css @@ -1,21 +1,21 @@ /* Edit icon on tiled grids -----------------------------*/ -.tiled_grid div.landscape, .tiled_grid div.portrait, .tiled_grid div.panorama { +.polaroid { position: relative; } -.tiled_grid div > a.edit { +.polaroid a.edit { background: #fff; border-radius: 3px; box-shadow: 1px 1px 2px rgba(0,0,0,0.3); - display: none; + display: none !important; left: 20px; line-height: 1.5; padding: 5px 10px; position: absolute; top: 20px; } -.tiled_grid div:hover > a.edit { - display: block; +.polaroid:hover > a.edit { + display: block !important; } diff --git a/public/css/default.css b/public/css/default.css index 5f61392..32ac1f9 100644 --- a/public/css/default.css +++ b/public/css/default.css @@ -177,46 +177,39 @@ i.space-invader.alt-7::before { } -/* Tiled grid ----------------*/ -.tiled_header { +/* Album and photo index pages +--------------------------------*/ +.album-index, .photo-index { + clear: both; +} + +.tiled-header > a { background: #fff; box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3); border-radius: 0.5rem; color: #000; - clear: both; - float: left; - margin: 0 0 1.5% 0; + display: inline-block; font: 400 18px/2.2 'Coda', sans-serif; + margin: 0 0 1.5% 0; + overflow: hidden; padding: 6px 22px; text-overflow: ellipsis; white-space: nowrap; - overflow: hidden; } -.tiled_grid { - margin: 0; - padding: 0; - list-style: none; -} -.tiled_grid div.landscape, .tiled_grid div.portrait, .tiled_grid div.panorama, -.tiled_grid div.duo, .tiled_grid div.single { +div.polaroid { background: #fff; box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3); - float: left; line-height: 0; - margin: 0 3.5% 3.5% 0; - overflow: hidden; position: relative; - width: 31%; } -.tiled_grid div img { +div.polaroid img { background: url('../images/nothumb.svg') center no-repeat; border: none; object-fit: cover; width: 100%; } -.tiled_grid div h4 { +div.polaroid h4 { color: #000; margin: 0; font: 400 18px 'Coda', sans-serif; @@ -226,101 +219,19 @@ i.space-invader.alt-7::before { white-space: nowrap; overflow: hidden; } -.tiled_grid div a { +div.polaroid a { + display: block; text-decoration: none; } -.tiled_grid div.landscape:hover, .tiled_grid div.portrait:hover, .tiled_grid div.panorama:hover, -.tiled_grid div.duo:hover, .tiled_grid div.single:hover { +div.polaroid:hover { box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); } -/* Panoramas */ -.tiled_grid div.panorama, .tiled_grid .tiled_row { - clear: both; - float: left; - width: 100%; - margin-right: 0; -} - -/* Tiling: one landscape, two tiles */ -.tiled_row .column_landscape { - float: left; - width: 65.5%; - margin: 0 3.5% 3.5% 0; -} -.tiled_row .column_landscape div { - width: auto; - margin: 0; -} - -.tiled_row .column_tiles_two { - float: left; - width: 31%; -} -.tiled_row .column_tiles_two div { - float: left; - width: 100%; - margin: 0 0 10% 0; -} - -/* Tiling: big portrait, four tiles */ -.tiled_row .column_portrait { - float: left; - width: 31%; - margin: 0 3.5% 3.5% 0; -} -.tiled_row .column_portrait div { - width: auto; - margin: 0; -} - -.tiled_row .column_tiles_four { - float: left; - width: 65.5%; -} -.tiled_row .column_tiles_four div { - float: left; - width: 47.45%; - margin: 0 5% 5% 0; -} - -/* Tiling: two tiles */ -.tiled_row .duo { - width: 48.25% !important; -} - -/* Tiling: one tile */ -.tiled_row .single { - width: 48.25% !important; -} - -/* Tiling: remove horizontal margin at end of row. */ -.tiled_row > div:nth-child(3n), -.tiled_row > .duo:nth-child(2) { - margin-right: 0 !important; -} -.tiled_row .column_tiles_four > div:nth-child(2n) { - margin-right: 0; -} - -/* Tiling: switch places for odd rows */ -.tiled_row:nth-child(odd) .column_landscape, -.tiled_row:nth-child(odd) .column_portrait { - float: right; - margin: 0 0 3.5% 3.5%; -} -.tiled_row:nth-child(odd) .column_tiles_four { - float: right; -} -.tiled_row:nth-child(odd) .column_tiles_two { - float: right; -} - /* Album title boxes ----------------------*/ .album_title_box { - margin-left: -46px; + margin-left: -2.85rem; width: 100%; } .album_title_box > a { @@ -330,7 +241,7 @@ i.space-invader.alt-7::before { border-bottom-left-radius: 0.5rem; display: inline-block; float: left; - font-size: 2em; + font-size: 2rem; line-height: 1; padding: 8px 10px; } @@ -341,7 +252,7 @@ i.space-invader.alt-7::before { border-bottom-right-radius: 0.5rem; float: left; font: inherit; - padding: 6px 22px; + padding: 0.4rem 1.3rem; max-width: 90%; margin: 0 0 1.5% 0; } @@ -550,27 +461,15 @@ a#previous_photo:hover, a#next_photo:hover { margin-left: 0; } - .tiled_header { + .tiled-header { font-size: 14px; margin: 0 0 3.5% 0; } - .tiled_grid div h4 { + .panorama h4 { font-size: 14px; padding: 15px 5px; } - .tiled_row > div, .tiled_row .single, .tiled_row .duo { - float: none !important; - width: 100% !important; - margin: 0 0 5% !important; - } - - .tiled_row > div > div { - float: none !important; - width: 100% !important; - margin: 0 0 5% !important; - } - #previous_photo, #next_photo { display: none; } diff --git a/templates/AlbumIndex.php b/templates/AlbumIndex.php index ebfe9c1..676b871 100644 --- a/templates/AlbumIndex.php +++ b/templates/AlbumIndex.php @@ -15,6 +15,7 @@ class AlbumIndex extends Template const TILE_WIDTH = 400; const TILE_HEIGHT = 300; + const TILE_RATIO = self::TILE_WIDTH / self::TILE_HEIGHT; public function __construct(array $albums, $show_edit_buttons = false, $show_labels = true) { @@ -26,57 +27,56 @@ class AlbumIndex extends Template public function html_main() { echo ' -