Skip to content

Commit 9d7b383

Browse files
committed
Improved error handling for invalid background images
1 parent 47f9ce4 commit 9d7b383

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

app/Functions/functions.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function findBackground($name)
4646
}
4747

4848
function analyzeImageBrightness($file) {
49-
49+
try {
5050
$file = base_path('assets/img/background-img/'.$file);
5151

5252
// Get image information using getimagesize
@@ -95,6 +95,9 @@ function analyzeImageBrightness($file) {
9595
} else {
9696
return 'light';
9797
}
98+
} catch (\Throwable $th) {
99+
return null;
100+
}
98101
}
99102

100103
function infoIcon($tip) {

resources/views/littlelink.blade.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
@endif
1313
@endforeach
1414

15-
@foreach($information as $info) @php $GLOBALS['themeName'] = $info->theme; @endphp @endforeach
16-
1715
<?php
1816
// Theme Config
19-
function theme($key){
17+
if (!function_exists('theme')) {
18+
function theme($key){
2019
$key = trim($key);
2120
$file = base_path('themes/' . $GLOBALS['themeName'] . '/config.php');
2221
if (file_exists($file)) {
@@ -25,13 +24,18 @@ function theme($key){
2524
return $config[$key];
2625
}}
2726
return null;}
27+
}
2828
2929
// Theme Custom Asset
30+
if (!function_exists('themeAsset')) {
3031
function themeAsset($path){
3132
$path = url('themes/' . $GLOBALS['themeName'] . '/extra/custom-assets/' . $path);
3233
return $path;}
34+
}
3335
?>
3436

37+
@foreach($information as $info) @php $GLOBALS['themeName'] = $info->theme; @endphp @endforeach
38+
3539
@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
3640

3741
@include('layouts.analytics')

0 commit comments

Comments
 (0)