Do you wish to register an account?
Browse Source

Use proxy and cached images on user info page

tags/v4.0.0-rc-1
Timothy Warren 3 years ago
parent
commit
1df71121eb
4 changed files with 17 additions and 9 deletions
  1. +2
    -1
      .gitignore
  2. +10
    -5
      app/views/me.php
  3. +0
    -0
      public/images/avatars/.gitkeep
  4. +5
    -3
      src/Controller/Index.php

+ 2
- 1
.gitignore View File

@@ -13,7 +13,7 @@ composer.lock
*.sqlite
*.db
*.sqlite3
apidocs/*
apidocs/**
tests/test_data/sessions/*
cache.properties
build/**
@@ -27,5 +27,6 @@ phinx.yml
Caddyfile
build/humbuglog.txt
public/images/anime/**
public/images/avatars/**
public/images/manga/**
public/images/characters/**

+ 10
- 5
app/views/me.php View File

@@ -9,7 +9,12 @@
<?= $attributes['name'] ?>
</a>
</h2>
<img src="<?= $attributes['avatar']['original'] ?>" alt="" />
<?php
$file = basename(parse_url($attributes['avatar']['original'], \PHP_URL_PATH));
$parts = explode('.', $file);
$ext = end($parts);
?>
<img src="<?= $urlGenerator->assetUrl('images/avatars', "{$data['id']}.{$ext}") ?>" alt="" />
</center>
<br />
<br />
@@ -65,13 +70,13 @@
<?php if ( ! empty($favorites['characters'])): ?>
<h4>Favorite Characters</h4>
<section class="media-wrap">
<?php foreach($favorites['characters'] as $char): ?>
<?php foreach($favorites['characters'] as $id => $char): ?>
<?php if ( ! empty($char['image']['original'])): ?>
<article class="small_character">
<?php $link = $url->generate('character', ['slug' => $char['slug']]) ?>
<div class="name"><?= $helper->a($link, $char['name']); ?></div>
<a href="<?= $link ?>">
<?= $helper->img($char['image']['original']) ?>
<?= $helper->img($urlGenerator->assetUrl('images/characters', "{$char['id']}.jpg")) ?>
</a>
</article>
<?php endif ?>
@@ -88,7 +93,7 @@
$titles = Kitsu::filterTitles($anime);
?>
<a href="<?= $link ?>">
<img src="<?= $anime['posterImage']['small'] ?>" width="220" alt="" />
<img src="<?= $urlGenerator->assetUrl('images/anime', "{$anime['id']}.jpg") ?>" width="220" alt="" />
</a>
<div class="name">
<a href="<?= $link ?>">
@@ -112,7 +117,7 @@
$titles = Kitsu::filterTitles($manga);
?>
<a href="<?= $link ?>">
<img src="<?= $manga['posterImage']['small'] ?>" width="220" alt="" />
<img src="<?= $urlGenerator->assetUrl('images/manga', "{$manga['id']}.jpg") ?>" width="220" alt="" />
</a>
<div class="name">
<a href="<?= $link ?>">


+ 0
- 0
public/images/avatars/.gitkeep View File


+ 5
- 3
src/Controller/Index.php View File

@@ -134,6 +134,10 @@ class Index extends BaseController {
$kitsuUrl .= "anime/poster_images/{$id}/small.{$ext}";
break;

case 'avatars':
$kitsuUrl .= "users/avatars/{$id}/original.{$ext}";
break;

case 'manga':
$kitsuUrl .= "manga/poster_images/{$id}/small.{$ext}";
break;
@@ -164,8 +168,6 @@ class Index extends BaseController {

unset($rawfavorites['data']);

// dump($rawfavorites);

foreach($rawfavorites as $item)
{
$rank = $item['attributes']['favRank'];
@@ -174,7 +176,7 @@ class Index extends BaseController {
$output[$key] = $output[$key] ?? [];
foreach ($fav as $id => $data)
{
$output[$key][$rank] = $data['attributes'];
$output[$key][$rank] = array_merge(['id' => $id], $data['attributes']);
}
}



Loading…
Cancel
Save