From 7370737e7f86615066c8c2584399805edce04dd6 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Wed, 17 Jan 2024 18:28:24 +0100 Subject: [PATCH] PhotosIndex: allow setting image as the album cover as well --- controllers/EditAsset.php | 12 ++++++++++++ templates/PhotosIndex.php | 20 ++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/controllers/EditAsset.php b/controllers/EditAsset.php index b6b999a..19cf70b 100644 --- a/controllers/EditAsset.php +++ b/controllers/EditAsset.php @@ -46,6 +46,18 @@ class EditAsset extends HTMLController header('Location: ' . BASEURL . '/' . $asset->getSubdir()); exit; } + else if (isset($_REQUEST['album_cover'], $_REQUEST['in']) && Session::validateSession('get')) + { + $tag = Tag::fromId($_REQUEST['in']); + $tag->id_asset_thumb = $asset->getId(); + $tag->save(); + + if (isset($_SERVER['HTTP_REFERER'])) + header('Location: ' . $_SERVER['HTTP_REFERER']); + else + header('Location: ' . BASEURL . '/' . $asset->getSubdir()); + exit; + } // Get a list of available photo albums $allAlbums = []; diff --git a/templates/PhotosIndex.php b/templates/PhotosIndex.php index 8a9328b..a104bca 100644 --- a/templates/PhotosIndex.php +++ b/templates/PhotosIndex.php @@ -13,7 +13,9 @@ class PhotosIndex extends Template protected $show_headers; protected $show_labels; protected $previous_header = ''; - protected $url_suffix; + + protected $edit_url_suffix; + protected $photo_url_suffix; const PANORAMA_WIDTH = 1256; const PANORAMA_HEIGHT = null; @@ -83,20 +85,25 @@ class PhotosIndex extends Template protected function editMenu(Image $image) { + $edit_url = $image->getEditUrl() . $this->edit_url_suffix; + echo '