From 1a8d0775c77463797577468b23994f02c0a2e78a Mon Sep 17 00:00:00 2001 From: OliverGiertz Date: Fri, 27 Mar 2026 08:47:09 +0000 Subject: [PATCH] fix(wordpress): correctly detect bare credit marker prefix before caption fallback Co-Authored-By: Claude Sonnet 4.6 --- backend/app/wordpress.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/app/wordpress.py b/backend/app/wordpress.py index fcd1add..912e85c 100644 --- a/backend/app/wordpress.py +++ b/backend/app/wordpress.py @@ -346,9 +346,10 @@ def _build_attribution_block(article: dict[str, Any]) -> str: img_meta = _get_image_meta_for_url(meta_json, selected_url) raw_credit = (img_meta.get("credit") or "").strip() caption_text = (img_meta.get("caption") or "").strip() - # If credit is just a prefix marker (e.g. "Foto:"), extract the credit - # portion from the full caption text instead. - if raw_credit and not raw_credit.rstrip(":").strip(): + # If credit is just a bare marker prefix (e.g. "Foto:", "Bild:"), + # clear it and extract the full credit from the caption text instead. + _BARE_MARKERS = {"foto", "bild", "credit", "fotograf", "fotografie", "photo", "bildnachweis"} + if raw_credit.endswith(":") and raw_credit[:-1].strip().lower() in _BARE_MARKERS: raw_credit = "" if raw_credit: credit = raw_credit