fix: Update Champion image URLs from CDN Cdragon to RAW

- Refactored the Champion model to use new image URLs for different attributes.
- Updated blade templates to fetch champion images with correct URLs.
This commit is contained in:
Rico van Zelst
2024-04-14 13:46:53 +02:00
parent 3478d5330b
commit 01b3e35e87
3 changed files with 32 additions and 46 deletions

View File

@@ -99,26 +99,18 @@ class Champion extends Model
return $this->hasMany(Streamer::class, 'champion_id', 'champion_id');
}
public function getChampionImageAttribute($centered = true): string
public function getChampionImageAttribute(): string
{
$url = 'https://cdn.communitydragon.org/latest/champion/'.$this->champion_id.'/splash-art';
return $centered ? $url.'/centered' : $url;
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';
}
public function getChampionImageLoadingAttribute(): string
{
return 'https://cdn.communitydragon.org/latest/champion/'.$this->champion_id.'/portrait';
}
public function getChampionImageTileAttribute(): string
{
return 'https://cdn.communitydragon.org/latest/champion/'.$this->champion_id.'/tile';
return 'https://raw.communitydragon.org/pbe/plugins/rcp-be-lol-game-data/global/default/v1/champion-tiles/' . $this->champion_id . '/' . $this->champion_id . '000.jpg';
}
public function getChampionSquareImageAttribute(): string
{
return 'https://cdn.communitydragon.org/latest/champion/'.$this->champion_id.'/square';
return 'https://raw.communitydragon.org/pbe/plugins/rcp-be-lol-game-data/global/default/v1/champion-icons/' . $this->champion_id . '.png';
}
public function getChampionAbilityIconQAttribute(): string

View File

@@ -17,7 +17,7 @@
<div class="absolute inset-0 aspect-video glow-shadow rounded-2xl"
style="--splash-color: {{ $champion->splash_color }}"></div>
<div class="relative overflow-hidden aspect-video rounded-2xl">
<img src="//wsrv.nl/?url={{ $champion->getChampionImageAttribute(false) }}&w=880&output=webp&q=85&il"
<img src="//wsrv.nl/?url={{ $champion->getChampionImageAttribute() }}&w=880&output=webp&q=85&il"
alt="{{ $champion->name }} Splash Art"
class="z-10 object-cover w-full h-full transition-transform duration-700 transform scale-100 hover:scale-105">
</div>

View File

@@ -18,14 +18,11 @@
<div
class="champ-card flex flex-col text-gray-700 bg-stone-800/40 shadow-md rounded-2xl bg-clip-border
border border-stone-800 hover:border-orange-500/10 hover:shadow-orange-500/10 @foreach ($roles[$key]->roles as $lane) POS-{{ $lane }} @endforeach">
<div
class="mx-4 mt-4 overflow-hidden border-2 h-52 rounded-2xl bg-clip-border border-orange-400/40">
<div class="mx-4 mt-4 overflow-hidden border-2 h-52 rounded-2xl bg-clip-border border-orange-400/40">
<a href="/champion/{{ $champion->slug }}">
<img @if ($key < 8) loading="eager" @else loading="lazy" @endif
src="//wsrv.nl/?url={{ $champion->getChampionImageAttribute() }}&w=380&output=webp&q=65&il"
class="object-cover w-full h-full"
alt="{{ $champion->name }} Splash Art"
/>
class="object-cover w-full h-full" alt="{{ $champion->name }} Splash Art" />
</a>
</div>
@@ -44,19 +41,16 @@
@foreach ($roles[$key]->roles as $lane)
<span class="sr-only">{{ $lane }}</span>
<img
{{Popper::arrow('translucent')->theme('dark')->position('bottom')->pop($lane)}}
@if($key < 8) loading="auto" @else loading="lazy"
@endif src="{{getRoleIcon($lane)}}"
alt="{{$lane}} Icon"
<img {{ Popper::arrow('translucent')->theme('dark')->position('bottom')->pop($lane) }}
@if ($key < 8) loading="auto" @else loading="lazy" @endif
src="{{ getRoleIcon($lane) }}" alt="{{ $lane }} Icon"
class="mr-1 w-7 h-7">
</p>
@endforeach
<div class="flex items-end justify-end w-full justify-items-end">
<p class="text-2xl text-right text-orange-300 md:text-lg hover:text-orange-400">
<a href="/champion/{{$champion->slug}}"
aria-label="[Detailed {{$champion->name}} info...]">
<a href="/champion/{{ $champion->slug }}" aria-label="[Detailed {{ $champion->name }} info...]">
<x-iconsax-bul-arrow-right class="w-8 transition-colors" />
</a>
</p>