diff options
| author | default <nobody@localhost> | 2024-10-27 09:02:45 +0100 |
|---|---|---|
| committer | default <nobody@localhost> | 2024-10-27 09:02:45 +0100 |
| commit | 4563b9c2f5bd98117d3bb95c192aaafe525c0ce1 (patch) | |
| tree | 1fd05f3b30f8a31673d7a9541e14c902eb7918e9 | |
| parent | be98082eee0e0d523560912cd7b5103028ea4826 (diff) | |
If an attached image URL is already in the post content, don't show it.
| -rw-r--r-- | html.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -1934,6 +1934,8 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, xs_html_add(snac_content, content_attachments); + const char *content = xs_dict_get(msg, "content"); + int c = 0; const xs_dict *a; while (xs_list_next(attach, &a, &c)) { @@ -1942,6 +1944,11 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, const char *name = xs_dict_get(a, "name"); if (xs_startswith(type, "image/") || strcmp(type, "Image") == 0) { + + /* if this image is already in the post content, skip */ + if (xs_str_in(content, href) != -1) + continue; + xs_html_add(content_attachments, xs_html_tag("a", xs_html_attr("href", href), |