diff mgallery.php @ 35:985596db0f01

Implement recursive depth album covers.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 02 May 2016 12:20:01 +0300
parents e786771dfaa5
children 3f16beb79f9e
line wrap: on
line diff
--- a/mgallery.php	Sat Apr 23 20:14:23 2016 +0300
+++ b/mgallery.php	Mon May 02 12:20:01 2016 +0300
@@ -179,7 +179,25 @@
     }
     else
     {
-      $atmp = ($galUseCoverImages && isset($data["image"])) ? $galImageURL.mgCleanPath(TRUE, $galPath, $filename, $galTNPath, $data["image"]) : $galAlbumIcon;
+      if ($galUseCoverImages && isset($data["image"]))
+      {
+        // Recursively determine the album cover image
+        $ptmp = [$galPath, $filename];
+        $curr = &$data;
+        while (is_array($curr["image"]))
+        {
+          $curr = &$curr["image"];
+          $ptmp[] = $curr["base"];
+        }
+
+        $ptmp[] = $galTNPath;
+        $ptmp[] = $curr["image"];
+        $atmp = $galImageURL.implode("/", mgCleanPathArray(TRUE, 0, count($ptmp), $ptmp));
+      }
+      else
+      // No album cover, use default
+        $atmp = $galAlbumIcon;
+
       echo
       "    <a href=\"".mgGetURL(mgCleanPath(TRUE, $galPath, $filename), FALSE)."\">".
       "<img class=\"albumIcon\" src=\"".$atmp."\" alt=\"".chentities($data["caption"])."\" />\n".