preview: add minimal preview for albums with no images

This commit is contained in:
mappu 2023-05-20 13:43:17 +12:00
parent 0a22d1ca8a
commit b146db9d0a

View File

@ -136,16 +136,15 @@ html, body {
return return
} }
if len(childIDs) == 0 { albumThumb := `/nothumb_340.png`
log.Printf("Failed to parse album '%s': no entries in album", fileID) if len(childIDs) > 0 {
http.Error(w, "Internal error", 500) albumThumb = `/thumb/m/` + childIDs[0]
return
} }
tmpl += ` tmpl += `
<div class="entry"> <div class="entry">
<div class="thumbnail"> <div class="thumbnail">
<a href="` + html.EscapeString(`/p/`+strings.Join(childIDs, `-`)) + `"><img loading="lazy" src="` + html.EscapeString(`/thumb/m/`+childIDs[0]) + `"></a> <a href="` + html.EscapeString(`/p/`+strings.Join(childIDs, `-`)) + `"><img loading="lazy" src="` + html.EscapeString(albumThumb) + `"></a>
<div class="thumbnail-overlay">` + fmt.Sprintf("%d", len(childIDs)) + ` image(s)</div> <div class="thumbnail-overlay">` + fmt.Sprintf("%d", len(childIDs)) + ` image(s)</div>
</div> </div>
<div class="properties"> <div class="properties">