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

@@ -8,32 +8,29 @@
class="text-3xl font-bold text-center text-transparent uppercase sm:text-4xl bg-gradient-to-bl from-orange-300 to-orange-500 bg-clip-text">
Champions</h1>
<div class="flex justify-center items-center mx-auto max-w-screen-xl mt-2.5">
<x-champions.lane-selector class="text-center"/>
<x-champions.lane-selector class="text-center" />
</div>
<div class="container flex items-center justify-center p-4 mx-auto mt-3">
<div class="grid grid-cols-1 gap-12 md:grid-cols-2 lg:grid-cols-4">
@foreach($champions as $key => $champion)
@foreach ($champions as $key => $champion)
<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">
<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"
/>
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">
<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" />
</a>
</div>
<div class="px-4 py-2">
<div class="flex items-center justify-between">
<p class="block text-base antialiased font-medium text-gray-100">
<a href="/champion/{{$champion->slug}}">
{{ $champion->name }}
<a href="/champion/{{ $champion->slug }}">
{{ $champion->name }}
</a>
</p>
<span class="text-xs text-stone-300">{{ $champion->title }}</span>
@@ -41,30 +38,27 @@
<div class="flex items-center mt-2">
<p class="flex text-sm text-gray-300">
@foreach($roles[$key]->roles as $lane)
<span class="sr-only">{{$lane}}</span>
@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...]">
<x-iconsax-bul-arrow-right class="w-8 transition-colors"/>
</a>
</p>
</div>
</div>
</div>
</div>
@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...]">
<x-iconsax-bul-arrow-right class="w-8 transition-colors" />
</a>
</p>
</div>
</div>
</div>
</div>
@endforeach
</div>
</div>
</section>