Code restructure push
This commit is contained in:
@@ -27,9 +27,17 @@ $classes = $classes ?? '';
|
||||
|
||||
// If no banner image provided, try to use random banner
|
||||
if (empty($bannerImage)) {
|
||||
$bannerFolder = 'assets/images/banners/';
|
||||
// Try to determine root path if not already set
|
||||
if (!isset($rootPath)) {
|
||||
$rootPath = $_SERVER['DOCUMENT_ROOT'] ?? dirname(__DIR__);
|
||||
}
|
||||
$bannerFolder = $rootPath . '/assets/images/banners/';
|
||||
$bannerImages = glob($bannerFolder . '*.{jpg,jpeg,png,webp}', GLOB_BRACE);
|
||||
$bannerImage = !empty($bannerImages) ? $bannerImages[array_rand($bannerImages)] : 'assets/images/base4/camping.jpg';
|
||||
// Convert absolute paths back to web-relative paths
|
||||
$bannerImages = array_map(function($path) use ($rootPath) {
|
||||
return str_replace($rootPath, '', $path);
|
||||
}, $bannerImages);
|
||||
$bannerImage = !empty($bannerImages) ? $bannerImages[array_rand($bannerImages)] : '/assets/images/base4/camping.jpg';
|
||||
}
|
||||
|
||||
// Add the page title to breadcrumbs as last item (not a link)
|
||||
|
||||
Reference in New Issue
Block a user