From 4e86847f7272b8d49d5210cfb954baa82cecf56b Mon Sep 17 00:00:00 2001 From: default Date: Sat, 28 Jan 2023 18:22:42 +0100 Subject: Image attachments in posts can now have descriptions ('alt text'). --- html.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'html.c') diff --git a/html.c b/html.c index 7aede65..7a388a1 100644 --- a/html.c +++ b/html.c @@ -1352,11 +1352,22 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, char *to = xs_dict_get(p_vars, "to"); char *sensitive = xs_dict_get(p_vars, "sensitive"); char *edit_id = xs_dict_get(p_vars, "edit_id"); + char *alt_text = xs_dict_get(p_vars, "alt_text"); xs *attach_list = xs_list_new(); + /* default alt text */ + if (xs_is_null(alt_text)) + alt_text = ""; + /* is attach_url set? */ - if (!xs_is_null(attach_url) && *attach_url != '\0') - attach_list = xs_list_append(attach_list, attach_url); + if (!xs_is_null(attach_url) && *attach_url != '\0') { + xs *l = xs_list_new(); + + l = xs_list_append(l, attach_url); + l = xs_list_append(l, alt_text); + + attach_list = xs_list_append(attach_list, l); + } /* is attach_file set? */ if (!xs_is_null(attach_file) && xs_type(attach_file) == XSTYPE_LIST) { @@ -1373,7 +1384,12 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, /* store */ static_put(&snac, id, payload + fo, fs); - attach_list = xs_list_append(attach_list, url); + xs *l = xs_list_new(); + + l = xs_list_append(l, url); + l = xs_list_append(l, alt_text); + + attach_list = xs_list_append(attach_list, l); } } -- cgit v1.2.3