# HG changeset patch # User Matti Hamalainen # Date 1586193971 -10800 # Node ID d66caa602023260966622286d06b41502e702452 # Parent af5ce7bf7eeb6b85fb7b4a5fc1fb30a88740b739 Add better checks for custom/user selected album cover image. diff -r af5ce7bf7eeb -r d66caa602023 mgtool.php --- a/mgtool.php Mon Apr 06 19:40:06 2020 +0300 +++ b/mgtool.php Mon Apr 06 20:26:11 2020 +0300 @@ -847,16 +847,22 @@ uasort($images, "mgSortFunc"); krsort($albums); - // Choose gallery album image + // Choose gallery album cover image if (count($images) > 0) { - if (isset($gallery["albumpic"]) && - isset($images[$gallery["albumpic"]])) + // Is the cover image set in the album data? + if (isset($gallery["albumpic"])) { - $parentEntry["image"] = $gallery["albumpic"]; + if (!isset($images[$gallery["albumpic"]])) + mgError("Album cover picture '".$gallery["albumpic"]."' set, but is not found in \n"); + else + $parentEntry["image"] = $gallery["albumpic"]; } - else + + // Got anything? + if (!isset($parentEntry["image"])) { + // No, use the last image in the album end($images); $parentEntry["image"] = key($images); }