From 0fb2b967fbddf9e3a8012e62ad82c5c53ad8ac52 Mon Sep 17 00:00:00 2001 From: Rico van Zelst Date: Sun, 14 Apr 2024 14:21:32 +0200 Subject: [PATCH] feat: Add support for uncentered champion images - Updated the Champion model to include an optional parameter for retrieving uncentered champion images. Adjusted image URLs in relevant views accordingly. --- app/Http/Controllers/ChampionController.php | 2 +- app/Models/Champion.php | 8 ++++-- .../components/champions/grid_info.blade.php | 2 +- .../components/sales/current_sales.blade.php | 28 +++++++++---------- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/app/Http/Controllers/ChampionController.php b/app/Http/Controllers/ChampionController.php index c8c47fa..28dd893 100644 --- a/app/Http/Controllers/ChampionController.php +++ b/app/Http/Controllers/ChampionController.php @@ -37,7 +37,7 @@ class ChampionController extends Controller $splashColor = Cache::remember( 'championSplashColorCache'.$champion->slug, $sixMonthsInSeconds, - static fn () => getAverageColorFromImageUrl('https://wsrv.nl/?url='.$champion->getChampionImageAttribute()) + static fn () => getAverageColorFromImageUrl('https://wsrv.nl/?url=' . $champion->getChampionImageAttribute(true)) ); $champion->splash_color = $splashColor; diff --git a/app/Models/Champion.php b/app/Models/Champion.php index 5ef5173..7c471da 100644 --- a/app/Models/Champion.php +++ b/app/Models/Champion.php @@ -99,9 +99,13 @@ class Champion extends Model return $this->hasMany(Streamer::class, 'champion_id', 'champion_id'); } - public function getChampionImageAttribute(): string + public function getChampionImageAttribute(bool $uncentered = false): string { - return 'https://raw.communitydragon.org/pbe/plugins/rcp-be-lol-game-data/global/default/v1/champion-splashes/'.$this->champion_id.'/'.$this->champion_id.'000.jpg'; + $baseUrl = 'https://raw.communitydragon.org/pbe/plugins/rcp-be-lol-game-data/global/default/v1/champion-splashes/'; + $imagePath = $uncentered ? 'uncentered/' : ''; + $imageUrl = $baseUrl . $imagePath . $this->champion_id . '/' . $this->champion_id . '000.jpg'; + + return $imageUrl; } public function getChampionImageTileAttribute(): string diff --git a/resources/views/components/champions/grid_info.blade.php b/resources/views/components/champions/grid_info.blade.php index 1f68a5a..fa6e884 100644 --- a/resources/views/components/champions/grid_info.blade.php +++ b/resources/views/components/champions/grid_info.blade.php @@ -17,7 +17,7 @@
- {{ $champion->name }} Splash Art
diff --git a/resources/views/components/sales/current_sales.blade.php b/resources/views/components/sales/current_sales.blade.php index 5986431..585a5c2 100644 --- a/resources/views/components/sales/current_sales.blade.php +++ b/resources/views/components/sales/current_sales.blade.php @@ -11,7 +11,7 @@

Champions on Sale

-
+