From ac56ac2b2da3bba78122b2e80eb36afc28e51056 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Tue, 23 Apr 2024 20:10:58 +0200 Subject: [PATCH] fix(gallery): show a fake image if no there is no icon (#2111) Signed-off-by: Ettore Di Giacinto --- core/http/elements/gallery.go | 40 ++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/core/http/elements/gallery.go b/core/http/elements/gallery.go index f2b4f8dd..c03750da 100644 --- a/core/http/elements/gallery.go +++ b/core/http/elements/gallery.go @@ -8,6 +8,10 @@ import ( "github.com/go-skynet/LocalAI/pkg/gallery" ) +const ( + NoImage = "https://upload.wikimedia.org/wikipedia/commons/6/65/No-Image-Placeholder.svg" +) + func DoneProgress(uid string) string { return elem.Div( attrs.Props{}, @@ -197,25 +201,27 @@ func ListModels(models []*gallery.GalleryModel) string { elems := []elem.Node{} - if m.Icon != "" { - elems = append(elems, - - elem.Div(attrs.Props{ - "class": "flex justify-center items-center", - }, - elem.A(attrs.Props{ - "href": "#!", - // "class": "justify-center items-center", - }, - elem.Img(attrs.Props{ - // "class": "rounded-t-lg object-fit object-center h-96", - "class": "rounded-t-lg max-h-48 max-w-96 object-cover mt-3", - "src": m.Icon, - }), - ), - )) + if m.Icon == "" { + m.Icon = NoImage } + elems = append(elems, + + elem.Div(attrs.Props{ + "class": "flex justify-center items-center", + }, + elem.A(attrs.Props{ + "href": "#!", + // "class": "justify-center items-center", + }, + elem.Img(attrs.Props{ + // "class": "rounded-t-lg object-fit object-center h-96", + "class": "rounded-t-lg max-h-48 max-w-96 object-cover mt-3", + "src": m.Icon, + }), + ), + )) + elems = append(elems, descriptionDiv(m), actionDiv(m)) modelsElements = append(modelsElements, elem.Div(