mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-10 03:50:38 +03:00
If a Page has an image, show it as an attachment.
This commit is contained in:
parent
64d3bb7e33
commit
4ab22b2c14
26
html.c
26
html.c
@ -1146,9 +1146,10 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
|
|||||||
s = xs_str_cat(s, "\n");
|
s = xs_str_cat(s, "\n");
|
||||||
|
|
||||||
/* add the attachments */
|
/* add the attachments */
|
||||||
char *attach;
|
xs_list *attach = xs_dict_get(msg, "attachment");
|
||||||
|
xs_dict *image = xs_dict_get(msg, "image");
|
||||||
|
|
||||||
if ((attach = xs_dict_get(msg, "attachment")) != NULL) { /** **/
|
if (!xs_is_null(attach) || !xs_is_null(image)) { /** **/
|
||||||
char *v;
|
char *v;
|
||||||
|
|
||||||
/* make custom css for attachments easier */
|
/* make custom css for attachments easier */
|
||||||
@ -1173,7 +1174,8 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
|
|||||||
|
|
||||||
xs *es1 = encode_html(name);
|
xs *es1 = encode_html(name);
|
||||||
xs *s1 = xs_fmt(
|
xs *s1 = xs_fmt(
|
||||||
"<a href=\"%s\" target=\"_blank\"><img src=\"%s\" alt=\"%s\" title=\"%s\" loading=\"lazy\"/></a>\n",
|
"<a href=\"%s\" target=\"_blank\">"
|
||||||
|
"<img src=\"%s\" alt=\"%s\" title=\"%s\" loading=\"lazy\"/></a>\n",
|
||||||
url, url, es1, es1);
|
url, url, es1, es1);
|
||||||
|
|
||||||
s = xs_str_cat(s, s1);
|
s = xs_str_cat(s, s1);
|
||||||
@ -1239,6 +1241,24 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if the message has an image, add it */
|
||||||
|
if (!xs_is_null(image)) {
|
||||||
|
if (!xs_is_null(image = xs_dict_get(image, "url"))) {
|
||||||
|
xs *es1;
|
||||||
|
if (!xs_is_null(v = xs_dict_get(msg, "name")))
|
||||||
|
es1 = encode_html(v);
|
||||||
|
else
|
||||||
|
es1 = xs_str_new(NULL);
|
||||||
|
|
||||||
|
xs *s1 = xs_fmt(
|
||||||
|
"<a href=\"%s\" target=\"_blank\">"
|
||||||
|
"<img src=\"%s\" alt=\"%s\" title=\"%s\" loading=\"lazy\"/></a>\n",
|
||||||
|
image, image, es1, es1);
|
||||||
|
|
||||||
|
s = xs_str_cat(s, s1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
s = xs_str_cat(s, "</p>\n");
|
s = xs_str_cat(s, "</p>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user