diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fb3ff1..245832b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - After such a failure, every request failed with "database is locked" for about 10 seconds: database connections now roll back unfinished writes when they're returned to the pool - The same photo listed twice in one post is shown once instead of failing the post - Replies didn't read as replies to IndieWeb readers and webmention receivers: on note pages `u-in-reply-to` sat inside an unrelated `h-cite`, and the home page didn't mark replies at all, so [Post Type Discovery](https://www.w3.org/TR/post-type-discovery/) saw notes (or photo posts). The reply context is now the entry's `u-in-reply-to h-cite`, and home page entries show "↩ In reply to" +- Photos without alt text used "Image" as their description, which IndieWeb readers passed on as if you'd written it. They now use the post's text (up to 150 characters), and fall back to "Image" only when the post has no text - Home page entries always have an `e-content`, so a photo post without text never gets an implied name (which readers would show as its caption) ### Changed diff --git a/docs/design/v2.6.5/2026-11-01-micropub-media-fixes.md b/docs/design/v2.6.5/2026-11-01-micropub-media-fixes.md index 0f771f8..5b91969 100644 --- a/docs/design/v2.6.5/2026-11-01-micropub-media-fixes.md +++ b/docs/design/v2.6.5/2026-11-01-micropub-media-fixes.md @@ -62,14 +62,19 @@ the rendered pages with mf2py found: - Page title for text-free posts follows PTD order: Repost, Like, Reply, Photo. +Photos without a caption take the post's text as alt (`partials/media.html` +`fallback_alt`) instead of the made-up "Image". The Micropub `q=source` +still reports the stored caption (`""`). + `tests/test_post_types.py` parses note pages and the home page with mf2py and runs PTD for notes, articles, photo posts (no text, caption, title), replies (with and without a photo) and reposts. ## Not changed (noted for later) -- Photos without alt text render `alt="Image"`, so parsers report alt text - nobody wrote (q=source correctly returns `""`). +- Text-free photos without alt text still render `alt="Image"`. Captioned + photos use their caption, and others now use the post's text (`display_media` + `fallback_alt`, the excerpt cut to 150 characters). - More than 4 photos are still cut to 4 without an error (ADR-057). - `video` and `audio` are ignored. This is allowed by the spec, and they diff --git a/templates/note.html b/templates/note.html index 5bfd222..c111540 100644 --- a/templates/note.html +++ b/templates/note.html @@ -44,7 +44,7 @@ {# u-photo placement: Per draft spec, u-photo must be direct child of h-entry, #} {# NOT inside e-content. Media is rendered ABOVE e-content to meet this requirement. #} - {{ display_media(note.media) }} + {{ display_media(note.media, note.excerpt|truncate(150)) }} {# e-content: note content BELOW media (per ADR-057) #}
diff --git a/templates/partials/media.html b/templates/partials/media.html index 8d2e396..c839e09 100644 --- a/templates/partials/media.html +++ b/templates/partials/media.html @@ -1,11 +1,12 @@ {# Reusable media display macro #} -{% macro display_media(media_items) %} +{# fallback_alt: for photos without a caption, usually the post's text (v2.6.5) #} +{% macro display_media(media_items, fallback_alt='') %} {% if media_items %}
{% for item in media_items %}
{{ item.caption or 'Image' }} {# No figcaption - caption is for alt text only #} diff --git a/templates/partials/note_preview.html b/templates/partials/note_preview.html index ad54abe..e6c1cdf 100644 --- a/templates/partials/note_preview.html +++ b/templates/partials/note_preview.html @@ -15,7 +15,7 @@ {{ reaction(note) }} - {{ display_media(note.media) }} + {{ display_media(note.media, note.excerpt|truncate(150)) }} {% if has_explicit_title %} {# Titled notes are articles: show a summary and link through #} diff --git a/tests/test_post_types.py b/tests/test_post_types.py index 56d6060..1c77a03 100644 --- a/tests/test_post_types.py +++ b/tests/test_post_types.py @@ -82,3 +82,17 @@ def test_post_type(app, client, h, monkeypatch, case): assert value(e["properties"]["in-reply-to"][0]) == props["in-reply-to"][0] if want == "photo" and "name" not in props: assert "name" not in e["properties"], "no implied name to show as a caption" + + +def test_photo_alt_text(app, client, h): + """Alt text is the caption, else the post's text, never made up (v2.6.5).""" + def alts(props): + url = client.post("/micropub", json={"type": ["h-entry"], "properties": props}, + headers=h).headers["Location"] + (entry,) = entries(mf2py.parse(doc=client.get(url.replace(SITE, "")).data.decode(), url=url)["items"]) + return [p["alt"] for p in entry["properties"]["photo"]] + + assert alts({"content": ["Beach day"], "photo": [{"value": upload(client, h), "alt": "Waves"}]}) == ["Waves"] + assert alts({"content": ["Beach day"], "photo": [upload(client, h, "blue")]}) == ["Beach day"] + assert alts({"name": ["Trip"], "content": ["Day one"], "photo": [upload(client, h, "green")]}) == ["Day one"] + assert alts({"photo": [upload(client, h, "gray")]}) == ["Image"]