Include lead image in feed item descriptions

The API already returns image_affiche_scale/image_full_scale for every
item (news and events alike), no extra request needed — just wasn't
being used. Embedded as an <img> at the top of the HTML description so
feed readers display it inline with the article.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
para
2026-09-25 23:53:19 +02:00
co-authored by Claude Sonnet 5
parent 13e5c94ee7
commit d917e76819
4 changed files with 36 additions and 11 deletions
+19 -4
View File
@@ -135,17 +135,32 @@ function attachments_html(array $item): string
}
/**
* Corps HTML complet d'un item (texte riche + pieces jointes), avec
* repli sur le resume court si le texte complet est vide.
* Image principale de l'item (deja fournie par l'API, aucune requete
* supplementaire necessaire). "paysage_affiche" est une taille
* intermediaire raisonnable pour une image de flux RSS.
*/
function full_body_html(array $item): string
function lead_image_html(array $item, string $title): string
{
$url = $item['image_affiche_scale'] ?? $item['image_full_scale'] ?? null;
if (!$url) {
return '';
}
return '<p><img src="' . htmlspecialchars($url, ENT_QUOTES, 'UTF-8') . '" alt="'
. htmlspecialchars($title, ENT_QUOTES, 'UTF-8') . '" /></p>';
}
/**
* Corps HTML complet d'un item (image + texte riche + pieces jointes),
* avec repli sur le resume court si le texte complet est vide.
*/
function full_body_html(array $item, string $title): string
{
$body = trim($item['text_fr']['data'] ?? '');
if ($body === '') {
$summary = strip_html($item['description_fr'] ?? $item['description'] ?? null);
$body = $summary !== '' ? '<p>' . htmlspecialchars($summary, ENT_QUOTES, 'UTF-8') . '</p>' : '';
}
return $body . attachments_html($item);
return lead_image_html($item, $title) . $body . attachments_html($item);
}
function rfc822(?string $isoDate): string