Update user details page to pull images directly from Kitsu

This commit is contained in:
Timothy Warren 2022-01-17 08:58:59 -05:00
parent eb897adbd1
commit e8a14fedf2
4 changed files with 10 additions and 5 deletions

View File

@ -16,7 +16,7 @@ use Aviat\AnimeClient\Kitsu;
<section class="flex flex-no-wrap"> <section class="flex flex-no-wrap">
<aside class="info"> <aside class="info">
<center> <center>
<?= $helper->img($urlGenerator->assetUrl($data['avatar']), ['alt' => '']); ?> <?= $helper->img($data['avatar'], ['alt' => '']); ?>
</center> </center>
<br /> <br />
<table class="media-details"> <table class="media-details">
@ -75,7 +75,7 @@ use Aviat\AnimeClient\Kitsu;
$rendered[] = $component->character( $rendered[] = $component->character(
$item['names']['canonical'], $item['names']['canonical'],
$url->generate('character', ['slug' => $item['slug']]), $url->generate('character', ['slug' => $item['slug']]),
$helper->picture("images/characters/{$item['id']}.webp") $helper->img($item['image']['original']['url'])
); );
} }
else else
@ -86,7 +86,7 @@ use Aviat\AnimeClient\Kitsu;
Kitsu::getFilteredTitles($item['titles']), Kitsu::getFilteredTitles($item['titles']),
), ),
$url->generate("{$type}.details", ['id' => $item['slug']]), $url->generate("{$type}.details", ['id' => $item['slug']]),
$helper->picture("images/{$type}/{$item['id']}.webp"), $helper->img(Kitsu::getPosterImage($item), ['width' => 220]),
); );
} }
} }

View File

@ -102,6 +102,11 @@ query ($slug: String!) {
original { original {
url url
} }
views {
url
height
width
}
} }
names { names {
alternatives alternatives

View File

@ -42,7 +42,7 @@ final class UserTransformer extends AbstractTransformer {
return User::from([ return User::from([
'about' => $base['about'], 'about' => $base['about'],
'avatar' => getLocalImg($base['avatarImage']['original']['url'], FALSE), 'avatar' => $base['avatarImage']['original']['url'],
'favorites' => $this->organizeFavorites($favorites), 'favorites' => $this->organizeFavorites($favorites),
'location' => $base['location'], 'location' => $base['location'],
'name' => $base['name'], 'name' => $base['name'],

View File

@ -343,7 +343,7 @@ final class Kitsu {
* @param int $size * @param int $size
* @return string * @return string
*/ */
public static function getPosterImage(array $base, int $size = 1): string public static function getPosterImage(array $base, int $size = 2): string
{ {
$rawUrl = $base['posterImage']['views'][$size]['url'] $rawUrl = $base['posterImage']['views'][$size]['url']
?? $base['posterImage']['original']['url'] ?? $base['posterImage']['original']['url']