feat: add YouTube video support for hero background
Generic: Repo Health / Site Health (push) Has been cancelled
Generic: Repo Health / Access control (push) Has been cancelled
Universal: Auto Version Bump / Version Bump (push) Has been cancelled
Update Server / Update Server (push) Has been cancelled
Generic: Repo Health / Release configuration (push) Has been cancelled
Generic: Repo Health / Scripts governance (push) Has been cancelled
Generic: Repo Health / Repository health (push) Has been cancelled

Detect YouTube URLs (youtube.com/watch, youtu.be, youtube.com/embed)
and render a privacy-enhanced iframe embed instead of a <video> tag.
Local video files still work as before via the <video> element.

- Extract YouTube video ID via regex in entry point
- Render iframe with autoplay, muted, looped, no controls
- Use youtube-nocookie.com for privacy
- Add pointer-events: none to prevent interaction with video layer
- Update video field label/description to mention YouTube support

Authored-by: Moko Consulting
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Miller
2026-05-28 14:39:27 -05:00
parent b126817d54
commit ac5c8d18b2
4 changed files with 19 additions and 8 deletions
+4 -1
View File
@@ -16,6 +16,7 @@ use Joomla\CMS\Language\Text;
/** @var array $heroImages */
/** @var int $slideInterval */
/** @var string $videoUrl */
/** @var string $youtubeId */
/** @var string $heroHeight */
/** @var string $overlayColor */
/** @var float $overlayOpacity */
@@ -40,7 +41,9 @@ $heightAttr = htmlspecialchars($heroHeight, ENT_QUOTES, 'UTF-8');
<?php endif; ?>
>
<?php // Background layer — single image, slideshow, or video ?>
<?php if ($heroMode === 'video' && $videoUrl) : ?>
<?php if ($heroMode === 'video' && $youtubeId) : ?>
<iframe class="mokojoomhero__video" src="https://www.youtube-nocookie.com/embed/<?php echo htmlspecialchars($youtubeId, ENT_QUOTES, 'UTF-8'); ?>?autoplay=1&mute=1&loop=1&playlist=<?php echo htmlspecialchars($youtubeId, ENT_QUOTES, 'UTF-8'); ?>&controls=0&showinfo=0&rel=0&modestbranding=1&playsinline=1" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
<?php elseif ($heroMode === 'video' && $videoUrl) : ?>
<video class="mokojoomhero__video" autoplay muted loop playsinline>
<source src="<?php echo htmlspecialchars($videoUrl, ENT_QUOTES, 'UTF-8'); ?>">
</video>