merge banners into covers: remove banner field, migrate files, add covers to search/home/repertoire cards

This commit is contained in:
Pontoporeia
2026-05-08 10:46:02 +02:00
parent e3896811c4
commit f3d9615562
15 changed files with 198 additions and 407 deletions

View File

@@ -9,7 +9,7 @@
* Responsibilities:
* - Validate the `id` GET parameter and load the thesis record
* - Enforce publication visibility (redirect to index on 404)
* - Resolve the OG image (banner → first image file)
* - Resolve the OG image (cover file → first image file)
* - Build the complete OG / Twitter Card tag array
* - Assemble the meta description from the synopsis
* - Collect WebVTT caption file paths for video pairing
@@ -155,16 +155,20 @@ class TfeController
}
/**
* Resolve the OG image URL: banner_path → first image file → empty string.
* Resolve the OG image URL: cover file → first image file → empty string.
*
* @param array<int, array<string, mixed>> $files
*/
private function resolveOgImage(array $files, ?string $bannerPath): string
private function resolveOgImage(array $files): string
{
if (!empty($bannerPath)) {
return self::BASE_URL . '/media.php?path=' . rawurlencode($bannerPath);
// Prefer the dedicated cover
foreach ($files as $file) {
if (($file['file_type'] ?? '') === 'cover') {
return self::BASE_URL . '/media.php?path=' . rawurlencode($file['file_path']);
}
}
// Fall back to first image file
foreach ($files as $file) {
$ext = strtolower(pathinfo($file['file_path'] ?? '', PATHINFO_EXTENSION));
if (in_array($ext, ['jpg', 'jpeg', 'png', 'gif', 'webp'], true)) {
@@ -183,7 +187,7 @@ class TfeController
*/
private function buildOgTags(array $data, int $thesisId, string $metaDescription): array
{
$ogImage = $this->resolveOgImage($data['files'] ?? [], $data['banner_path'] ?? null);
$ogImage = $this->resolveOgImage($data['files'] ?? []);
$title = $data['title'] . (!empty($data['authors']) ? ' ' . $data['authors'] : '');
$imageAlt = $data['title'] . (!empty($data['authors']) ? ' par ' . $data['authors'] : '');