changeset 79:8d8b361a76af

Allow setting "albumpic" in gallery.info for each album, e.g. forced album cover picture.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 14 Sep 2016 22:16:36 +0300
parents b7f2e643279f
children 121613e40d87
files mgtool.php
diffstat 1 files changed, 16 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mgtool.php	Wed Sep 14 20:58:14 2016 +0300
+++ b/mgtool.php	Wed Sep 14 22:16:36 2016 +0300
@@ -392,15 +392,25 @@
     // Choose gallery album image
     if (count($images) > 0)
     {
-      end($images);
-      $parentEntry["image"] = key($images);
+      if (isset($gallery["albumpic"]) &&
+          isset($images[$gallery["albumpic"]]))
+      {
+        $parentEntry["image"] = $gallery["albumpic"];
+      }
+      else
+      {
+        end($images);
+        $parentEntry["image"] = key($images);
+      }
     }
     else
-    foreach ($albums as $aid => &$adata)
-    if (isset($adata["image"]))
     {
-      $parentEntry["image"] = &$adata;
-      break;
+      foreach ($albums as $aid => &$adata)
+      if (isset($adata["image"]))
+      {
+        $parentEntry["image"] = &$adata;
+        break;
+      }
     }
   }