Fix favicon: support JPG/WebP/GIF, add logging, fix path resolution
Some checks failed
Repo Health / Access control (push) Successful in 1s
Auto-Update SHA Hash / Update SHA-256 Hash in updates.xml (release) Failing after 5s
Repo Health / Scripts governance (push) Successful in 3s
Repo Health / Release configuration (push) Failing after 3s
Repo Health / Repository health (push) Failing after 3s

- Support all common image formats (PNG, JPEG, GIF, WebP, BMP)
  not just PNG — uses getimagesize() to detect type
- Add Log::add() warnings when generation fails (GD missing,
  file not found, unsupported format)
- Fix source path: try both direct path and images/ prefix
  to handle Joomla media field variations

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Miller
2026-04-18 12:24:42 -05:00
parent 326d1c6a6f
commit 2ad624a48c
2 changed files with 33 additions and 3 deletions

View File

@@ -71,7 +71,13 @@ $templatePath = 'media/templates/site/mokocassiopeia';
$faviconHeadTags = '';
if ($params_favicon_source) {
require_once __DIR__ . '/helper/favicon.php';
$faviconSourceAbs = JPATH_ROOT . '/' . ltrim($params_favicon_source, '/');
// Joomla's media field may return 'images/file.png' or just 'file.png'
$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;
}
$faviconOutputDir = JPATH_ROOT . '/images/favicons';
$faviconUrlBase = Uri::root(true) . '/images/favicons';