Improved error handling for invalid background images

This commit is contained in:
Julian Prieber 2023-07-19 14:01:13 +02:00
parent 47f9ce4a01
commit 9d7b383c4e
2 changed files with 11 additions and 4 deletions

View File

@ -46,7 +46,7 @@ function findBackground($name)
}
function analyzeImageBrightness($file) {
try {
$file = base_path('assets/img/background-img/'.$file);
// Get image information using getimagesize
@ -95,6 +95,9 @@ function analyzeImageBrightness($file) {
} else {
return 'light';
}
} catch (\Throwable $th) {
return null;
}
}
function infoIcon($tip) {

View File

@ -12,11 +12,10 @@
@endif
@endforeach
@foreach($information as $info) @php $GLOBALS['themeName'] = $info->theme; @endphp @endforeach
<?php
// Theme Config
function theme($key){
if (!function_exists('theme')) {
function theme($key){
$key = trim($key);
$file = base_path('themes/' . $GLOBALS['themeName'] . '/config.php');
if (file_exists($file)) {
@ -25,13 +24,18 @@ $file = base_path('themes/' . $GLOBALS['themeName'] . '/config.php');
return $config[$key];
}}
return null;}
}
// Theme Custom Asset
if (!function_exists('themeAsset')) {
function themeAsset($path){
$path = url('themes/' . $GLOBALS['themeName'] . '/extra/custom-assets/' . $path);
return $path;}
}
?>
@foreach($information as $info) @php $GLOBALS['themeName'] = $info->theme; @endphp @endforeach
@if(theme('enable_custom_code') == "true" and theme('enable_custom_head') == "true" and env('ALLOW_CUSTOM_CODE_IN_THEMES') == 'true')@include($GLOBALS['themeName'] . '.extra.custom-head')@endif
@include('layouts.analytics')