hardfix imgvar
All checks were successful
Deploy / CreateImage (push) Successful in 2m20s
Deploy / DeployService (push) Successful in 22s

This commit is contained in:
skeris 2025-04-02 01:44:59 +03:00
parent cb2df810ed
commit 1a7a15f478

@ -73,13 +73,27 @@ var tmplFuncs = template.FuncMap{
}
func RenderImage(content string) template.HTML {
contents := strings.Split(content, "`,`")
var builder strings.Builder
for i, cnt := range contents {
if i == 0 {
cnt = strings.TrimPrefix(cnt, "`")
}
if i == len(contents)-1 {
cnt = strings.TrimSuffix(cnt, "`")
}
var res model.ImageContent
err := json.Unmarshal([]byte(content), &res)
err := json.Unmarshal([]byte(cnt), &res)
if err != nil {
return SplitContent(content)
} else {
builder.WriteString(fmt.Sprintf("<td>%s<br><img class=\"image\" style=\"width:100%%; max-width:250px; max-height:250px\" src=\"%s\"/></td>", res.Description, res.Image))
}
tpl := template.HTML(fmt.Sprintf("<td>%s<br><img class=\"image\" style=\"width:100%%; max-width:250px; max-height:250px\" src=\"%s\"/></td>", res.Description, res.Image))
return tpl
}
return template.HTML(builder.String())
}
func SplitContent(content string) template.HTML {