In HTML images, move the loading=lazy BEFORE the src attribute.

This may (or may not, not completely sure) avoid this Firefox bug:

https://bugzilla.mozilla.org/show_bug.cgi?id=1647077
This commit is contained in:
default 2023-08-24 06:52:42 +02:00
parent 4bc619e2fc
commit 5518bb509b

13
html.c
View file

@ -78,7 +78,7 @@ xs_str *actor_name(xs_dict *actor)
if (n && i) { if (n && i) {
char *u = xs_dict_get(i, "url"); char *u = xs_dict_get(i, "url");
xs *img = xs_fmt("<img src=\"%s\" style=\"height: 1em; vertical-align: middle;\" loading=\"lazy\"/>", u); xs *img = xs_fmt("<img loading=\"lazy\" src=\"%s\" style=\"height: 1em; vertical-align: middle;\"/>", u);
name = xs_replace_i(name, n, img); name = xs_replace_i(name, n, img);
} }
@ -110,8 +110,8 @@ xs_str *html_actor_icon(xs_str *os, char *actor,
avatar = xs_fmt("data:image/png;base64, %s", default_avatar_base64()); avatar = xs_fmt("data:image/png;base64, %s", default_avatar_base64());
{ {
xs *s1 = xs_fmt("<p><img class=\"snac-avatar\" src=\"%s\" alt=\"\" " xs *s1 = xs_fmt("<p><img class=\"snac-avatar\" loading=\"lazy\" "
"loading=\"lazy\"/>\n", avatar); "src=\"%s\" alt=\"\"/>\n", avatar);
s = xs_str_cat(s, s1); s = xs_str_cat(s, s1);
} }
@ -1164,8 +1164,9 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
if (n && i) { if (n && i) {
char *u = xs_dict_get(i, "url"); char *u = xs_dict_get(i, "url");
xs *img = xs_fmt("<img src=\"%s\" style=\"height: 2em; vertical-align: middle;\" " xs *img = xs_fmt("<img loading=\"lazy\" src=\"%s\" "
"loading=\"lazy\" title=\"%s\"/>", u, n); "style=\"height: 2em; vertical-align: middle;\" "
"title=\"%s\"/>", u, n);
c = xs_replace_i(c, n, img); c = xs_replace_i(c, n, img);
} }
@ -1341,7 +1342,7 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
if (xs_startswith(t, "image/") || strcmp(t, "Image") == 0) { if (xs_startswith(t, "image/") || strcmp(t, "Image") == 0) {
s1 = xs_fmt( s1 = xs_fmt(
"<a href=\"%s\" target=\"_blank\">" "<a href=\"%s\" target=\"_blank\">"
"<img src=\"%s\" alt=\"%s\" title=\"%s\" loading=\"lazy\"/></a>\n", "<img loading=\"lazy\" src=\"%s\" alt=\"%s\" title=\"%s\"/></a>\n",
url, url, es1, es1); url, url, es1, es1);
} }
else else