getDocument()->getWebAssetManager(); $wa->getRegistry()->addExtensionRegistryFile('mod_mokojoomhero'); $wa->usePreset('mod_mokojoomhero'); // Module parameters $heroMode = $params->get('heroMode', 'images'); $imageFolder = $params->get('imageFolder', 'images/heroes'); $imageCount = (int) $params->get('imageCount', 5); $slideInterval = (int) $params->get('slideInterval', 5000); $videoFile = $params->get('videoFile', ''); $heroHeight = $params->get('heroHeight', '60vh'); $overlayColor = $params->get('overlayColor', '#000000'); $overlayOpacity = (float) $params->get('overlayOpacity', 0.5); $textAlign = $params->get('textAlign', 'center'); $textColor = $params->get('textColor', '#ffffff'); $heroContent = $params->get('heroContent', ''); $showCard = (bool) $params->get('showCard', 1); $cardDelay = (int) $params->get('cardDelay', 0); $showMuteToggle = (bool) $params->get('showMuteToggle', 0); $localVideoFile = $params->get('localVideoFile', ''); // Collect hero images $heroImages = []; if ($heroMode === 'images') { $folderPath = JPATH_ROOT . '/' . ltrim($imageFolder, '/'); if (is_dir($folderPath)) { $allowed = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'avif', 'svg']; $all = []; foreach (new DirectoryIterator($folderPath) as $file) { if ($file->isFile() && in_array(strtolower($file->getExtension()), $allowed, true)) { $all[] = $file->getFilename(); } } if ($all) { shuffle($all); $picked = array_slice($all, 0, min($imageCount, 5)); foreach ($picked as $filename) { $heroImages[] = Uri::root() . $imageFolder . '/' . $filename; } } } } // Build video URL — smartly detect YouTube, Vimeo, or local/direct file $videoUrl = ''; $youtubeId = ''; $vimeoId = ''; if ($heroMode === 'localvideo' && $localVideoFile) { $videoUrl = Uri::root() . ltrim($localVideoFile, '/'); } elseif ($heroMode === 'video' && $videoFile) { // YouTube: watch, embed, shorts, youtu.be, with optional timestamps/params if (preg_match('/(?:youtube\.com\/(?:watch\?.*v=|embed\/|shorts\/|v\/)|youtu\.be\/)([\w-]{11})/', $videoFile, $m)) { $youtubeId = $m[1]; // Vimeo: vimeo.com/123456 or player.vimeo.com/video/123456 } elseif (preg_match('/vimeo\.com\/(?:video\/)?(\d+)/', $videoFile, $m)) { $vimeoId = $m[1]; } else { // Direct URL or local file path $videoUrl = (strpos($videoFile, '://') !== false) ? $videoFile : Uri::root() . ltrim($videoFile, '/'); } } // Module content from the editor (overlay text) $content = $module->content ?? ''; require ModuleHelper::getLayoutPath('mod_mokojoomhero', $params->get('layout', 'default'));