diff --git a/src/index.php b/src/index.php index 2c207cb..989cc5f 100644 --- a/src/index.php +++ b/src/index.php @@ -71,12 +71,25 @@ $templatePath = 'media/templates/site/mokocassiopeia'; $faviconHeadTags = ''; if ($params_favicon_source) { require_once __DIR__ . '/helper/favicon.php'; - // Joomla's media field may return 'images/file.png' or just 'file.png' + // Joomla's media field returns paths like: + // 'images/logo.png' (images folder) + // 'media/templates/site/mokocassiopeia/images/logo.png' (template media) + // 'logo.png' (bare filename) $faviconSourceRel = ltrim($params_favicon_source, '/'); $faviconSourceAbs = JPATH_ROOT . '/' . $faviconSourceRel; - // If not found, try prepending images/ - if (!is_file($faviconSourceAbs) && !str_starts_with($faviconSourceRel, 'images/')) { - $faviconSourceAbs = JPATH_ROOT . '/images/' . $faviconSourceRel; + // Try common prefixes if not found + if (!is_file($faviconSourceAbs)) { + $candidates = [ + JPATH_ROOT . '/images/' . $faviconSourceRel, + JPATH_ROOT . '/media/templates/site/' . $this->template . '/' . $faviconSourceRel, + JPATH_ROOT . '/media/templates/site/' . $this->template . '/images/' . basename($faviconSourceRel), + ]; + foreach ($candidates as $candidate) { + if (is_file($candidate)) { + $faviconSourceAbs = $candidate; + break; + } + } } $faviconOutputDir = JPATH_ROOT . '/images/favicons'; $faviconUrlBase = Uri::root(true) . '/images/favicons';