mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 10:10:48 +01:00
fix: Handle exceptions in image processing functions
- Catch exceptions when reading image content to prevent errors. - Adjust image resizing dimensions for better display.
This commit is contained in:
@@ -20,9 +20,13 @@ function getAverageColorFromImageUrl($imageUrl): string
|
||||
{
|
||||
$imgManager = new ImageManager(new Driver());
|
||||
|
||||
try {
|
||||
$img = $imgManager->read(file_get_contents($imageUrl));
|
||||
} catch (Exception $e) {
|
||||
return '#904f2c';
|
||||
}
|
||||
|
||||
$img->resize(24, 24);
|
||||
$img->resize(32, 32);
|
||||
|
||||
$totalR = 0;
|
||||
$totalG = 0;
|
||||
|
||||
@@ -37,7 +37,7 @@ class ChampionController extends Controller
|
||||
$splashColor = Cache::remember(
|
||||
'championSplashColorCache' . $champion->slug,
|
||||
$sixMonthsInSeconds,
|
||||
static fn () => getAverageColorFromImageUrl($champion->getChampionImageAttribute())
|
||||
static fn () => getAverageColorFromImageUrl('https://wsrv.nl/?url=' . $champion->getChampionImageAttribute())
|
||||
);
|
||||
|
||||
$champion->splash_color = $splashColor;
|
||||
|
||||
@@ -63,7 +63,7 @@ class ChampionSkinController extends Controller
|
||||
$splashColor = Cache::remember(
|
||||
'championSkinSplashColorCache' . $championSkin->slug,
|
||||
60 * 60 * 120,
|
||||
static fn () => getAverageColorFromImageUrl($championSkin->getSkinImageAttribute())
|
||||
getAverageColorFromImageUrl('https://wsrv.nl/?url=' . $championSkin->getSkinImageAttribute())
|
||||
);
|
||||
|
||||
$skin->splash_color = $splashColor;
|
||||
|
||||
Reference in New Issue
Block a user