summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2023-07-13 23:41:22 +0200
committerGravatar default2023-07-13 23:41:22 +0200
commit4ab22b2c14cd0a94b05488d247b5669922415f5e (patch)
tree95d1b75cb14ab375a19db38a3a8fcbf3ff774068
parentFixed Link HTML. (diff)
downloadsnac2-4ab22b2c14cd0a94b05488d247b5669922415f5e.tar.gz
snac2-4ab22b2c14cd0a94b05488d247b5669922415f5e.tar.xz
snac2-4ab22b2c14cd0a94b05488d247b5669922415f5e.zip
If a Page has an image, show it as an attachment.
-rw-r--r--html.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/html.c b/html.c
index 9f587f1..5598a4f 100644
--- a/html.c
+++ b/html.c
@@ -1146,9 +1146,10 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
1146 s = xs_str_cat(s, "\n"); 1146 s = xs_str_cat(s, "\n");
1147 1147
1148 /* add the attachments */ 1148 /* add the attachments */
1149 char *attach; 1149 xs_list *attach = xs_dict_get(msg, "attachment");
1150 xs_dict *image = xs_dict_get(msg, "image");
1150 1151
1151 if ((attach = xs_dict_get(msg, "attachment")) != NULL) { /** **/ 1152 if (!xs_is_null(attach) || !xs_is_null(image)) { /** **/
1152 char *v; 1153 char *v;
1153 1154
1154 /* make custom css for attachments easier */ 1155 /* 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,
1173 1174
1174 xs *es1 = encode_html(name); 1175 xs *es1 = encode_html(name);
1175 xs *s1 = xs_fmt( 1176 xs *s1 = xs_fmt(
1176 "<a href=\"%s\" target=\"_blank\"><img src=\"%s\" alt=\"%s\" title=\"%s\" loading=\"lazy\"/></a>\n", 1177 "<a href=\"%s\" target=\"_blank\">"
1178 "<img src=\"%s\" alt=\"%s\" title=\"%s\" loading=\"lazy\"/></a>\n",
1177 url, url, es1, es1); 1179 url, url, es1, es1);
1178 1180
1179 s = xs_str_cat(s, s1); 1181 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,
1239 } 1241 }
1240 } 1242 }
1241 1243
1244 /* if the message has an image, add it */
1245 if (!xs_is_null(image)) {
1246 if (!xs_is_null(image = xs_dict_get(image, "url"))) {
1247 xs *es1;
1248 if (!xs_is_null(v = xs_dict_get(msg, "name")))
1249 es1 = encode_html(v);
1250 else
1251 es1 = xs_str_new(NULL);
1252
1253 xs *s1 = xs_fmt(
1254 "<a href=\"%s\" target=\"_blank\">"
1255 "<img src=\"%s\" alt=\"%s\" title=\"%s\" loading=\"lazy\"/></a>\n",
1256 image, image, es1, es1);
1257
1258 s = xs_str_cat(s, s1);
1259 }
1260 }
1261
1242 s = xs_str_cat(s, "</p>\n"); 1262 s = xs_str_cat(s, "</p>\n");
1243 } 1263 }
1244 1264