commit 4b75b2a75fcd0b5e8d6de155ac38a70b29fc81fb
parent 1b1cb2dc384df37b753e1df65e995b81b341ff34
Author: grunfink <grunfink@noreply.codeberg.org>
Date: Fri, 16 Jun 2023 15:11:18 +0000
Merge pull request 'added titles to images and emojis' (#54) from Haijo7/snac2:titles into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/54
Diffstat:
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/html.c b/html.c
@@ -967,7 +967,7 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
if (n && i) {
char *u = xs_dict_get(i, "url");
xs *img = xs_fmt("<img src=\"%s\" style=\"height: 1em\" "
- "loading=\"lazy\"/>", u);
+ "loading=\"lazy\" title=\"%s\"/>", u, n);
c = xs_replace_i(c, n, img);
}
@@ -1073,9 +1073,11 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
char *name = xs_dict_get(v, "name");
if (url != NULL) {
+ if (xs_is_null(name))
+ name = "";
xs *s1 = xs_fmt(
- "<a href=\"%s\" target=\"_blank\"><img src=\"%s\" alt=\"%s\" loading=\"lazy\"/></a>\n",
- url, url, xs_is_null(name) ? "" : name);
+ "<a href=\"%s\" target=\"_blank\"><img src=\"%s\" alt=\"%s\" title=\"%s\" loading=\"lazy\"/></a>\n",
+ url, url, name, name);
s = xs_str_cat(s, s1);
}