feat: automaticke alt texty s moznostou rucneho prepisu (uloha 14)

- produkt: nazov produktu, ostatne obrazky: nadpis okna / nazov modulu
- z alt textu sa odstrania HTML znacky (napr. <br> v nadpisoch)
- pri kazdom obrazku pole Alt text; ak je vyplnene, ma prednost

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub_HostacnyandClaude Opus 5.5 committed 2026-10-19 10:24:58 +02:00
1 parent 23ac4dc830
commit d43a1dae40
5 files changed
+96 -12

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
// Alt text obrázka: prvý neprázdny kandidát (ručne zadaný alt, názov produktu, nadpis okna...),
// bez HTML značiek (napr. <br> v nadpisoch) a nadbytočných medzier
export function pickAlt(...candidates: Array<string | null | undefined>): string {
for (const c of candidates) {
const clean = stripTags(c);
if (clean) return clean;
}
return '';
}
function stripTags(str: string | null | undefined): string {
if (!str) return '';
return String(str)
.replace(/<br\s*\/?>/gi, ' ')
.replace(/<[^>]*>/g, '')
.replace(/\s+/g, ' ')
.trim();
}