Browse Source

lazy load doesn't do anything on base64 encoded images since they are loaded as part of the HTML. Only works for additional requests.

main
rra 3 years ago
parent
commit
1d07904459
  1. 4
      distribusi.go

4
distribusi.go

@ -576,10 +576,10 @@ func getHref(c *cli.Context, fpath string, mtype string) (bool, string, error) {
thumb, err := genThumb(c, fpath, caption) thumb, err := genThumb(c, fpath, caption)
if err != nil { if err != nil {
logrus.Debugf("failed to generate thumbnail for %s, showing original image", fpath) logrus.Debugf("failed to generate thumbnail for %s, showing original image", fpath)
href = fmt.Sprintf("<img class='%s' src=\"%s\" />", stype, fname) href = fmt.Sprintf("<img class='%s' loading='lazy' src=\"%s\" />", stype, fname)
} else { } else {
href = fmt.Sprintf( href = fmt.Sprintf(
"<figure><a href=\"%s\"><img class='thumbnail' loading='lazy' src='data:image/jpg;base64,%s'></a><figcaption>%s</figcaption></figure>", "<figure><a href=\"%s\"><img class='thumbnail' src='data:image/jpg;base64,%s'></a><figcaption>%s</figcaption></figure>",
fname, thumb, caption, fname, thumb, caption,
) )
} }

Loading…
Cancel
Save