Skip to content

Commit ac56ac2

Browse files
authored
fix(gallery): show a fake image if no there is no icon (#2111)
Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent 34c3f56 commit ac56ac2

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

core/http/elements/gallery.go

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import (
88
"github.com/go-skynet/LocalAI/pkg/gallery"
99
)
1010

11+
const (
12+
NoImage = "https://upload.wikimedia.org/wikipedia/commons/6/65/No-Image-Placeholder.svg"
13+
)
14+
1115
func DoneProgress(uid string) string {
1216
return elem.Div(
1317
attrs.Props{},
@@ -197,24 +201,26 @@ func ListModels(models []*gallery.GalleryModel) string {
197201

198202
elems := []elem.Node{}
199203

200-
if m.Icon != "" {
201-
elems = append(elems,
204+
if m.Icon == "" {
205+
m.Icon = NoImage
206+
}
207+
208+
elems = append(elems,
202209

203-
elem.Div(attrs.Props{
204-
"class": "flex justify-center items-center",
210+
elem.Div(attrs.Props{
211+
"class": "flex justify-center items-center",
212+
},
213+
elem.A(attrs.Props{
214+
"href": "#!",
215+
// "class": "justify-center items-center",
205216
},
206-
elem.A(attrs.Props{
207-
"href": "#!",
208-
// "class": "justify-center items-center",
209-
},
210-
elem.Img(attrs.Props{
211-
// "class": "rounded-t-lg object-fit object-center h-96",
212-
"class": "rounded-t-lg max-h-48 max-w-96 object-cover mt-3",
213-
"src": m.Icon,
214-
}),
215-
),
216-
))
217-
}
217+
elem.Img(attrs.Props{
218+
// "class": "rounded-t-lg object-fit object-center h-96",
219+
"class": "rounded-t-lg max-h-48 max-w-96 object-cover mt-3",
220+
"src": m.Icon,
221+
}),
222+
),
223+
))
218224

219225
elems = append(elems, descriptionDiv(m), actionDiv(m))
220226
modelsElements = append(modelsElements,

0 commit comments

Comments
 (0)