Mercurial > hg > mgallery
diff mgtool.php @ 317:d66caa602023
Add better checks for custom/user selected album cover image.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 06 Apr 2020 20:26:11 +0300 |
parents | af5ce7bf7eeb |
children | bf4115b6dc2a |
line wrap: on
line diff
--- 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); }