change format of avatar and 2D preview to WebP
This commit is contained in:
parent
361868038f
commit
12dab489d6
@ -63,7 +63,7 @@ class TextureController extends Controller
|
||||
$lastModified = $disk->lastModified($hash);
|
||||
|
||||
return Image::make($image)
|
||||
->response('png', 100)
|
||||
->response('webp', 100)
|
||||
->setLastModified(Carbon::createFromTimestamp($lastModified));
|
||||
}
|
||||
);
|
||||
@ -125,7 +125,7 @@ class TextureController extends Controller
|
||||
if (is_null($texture) || $disk->missing($texture->hash)) {
|
||||
return Image::make(resource_path("misc/textures/avatar$mode.png"))
|
||||
->resize($size, $size)
|
||||
->response('png', 100);
|
||||
->response('webp', 100);
|
||||
}
|
||||
|
||||
$hash = $texture->hash;
|
||||
@ -145,7 +145,7 @@ class TextureController extends Controller
|
||||
|
||||
return Image::make($image)
|
||||
->resize($size, $size)
|
||||
->response('png', 100)
|
||||
->response('webp', 100)
|
||||
->setLastModified($lastModified);
|
||||
}
|
||||
);
|
||||
|
@ -5,7 +5,7 @@ import { ExpirationPlugin } from 'workbox-expiration'
|
||||
registerRoute(
|
||||
/\/preview\/\d+/,
|
||||
new CacheFirst({
|
||||
cacheName: 'texture-preview-v1',
|
||||
cacheName: 'texture-preview-v2',
|
||||
fetchOptions: {
|
||||
credentials: 'omit',
|
||||
},
|
||||
@ -26,7 +26,7 @@ registerRoute(
|
||||
registerRoute(
|
||||
/\/avatar\/user\/\d+/,
|
||||
new StaleWhileRevalidate({
|
||||
cacheName: 'avatar-v1',
|
||||
cacheName: 'avatar-v2',
|
||||
fetchOptions: {
|
||||
credentials: 'omit',
|
||||
},
|
||||
|
@ -50,6 +50,7 @@
|
||||
- Reduced times of sending verification email.
|
||||
- Changed icon of "Walking/Running" button of skin viewer.
|
||||
- Changed API of retrieving all players.
|
||||
- Changed format of avatar and 2D preview to WebP.
|
||||
|
||||
## Fixed
|
||||
|
||||
|
@ -50,6 +50,7 @@
|
||||
- 减少发送验证邮件的次数
|
||||
- 更换皮肤预览器的「行走/奔跑」按钮图标
|
||||
- 更改获取角色的 API
|
||||
- 头像和预览图的格式改为 WebP
|
||||
|
||||
## 修复
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
{% endif %}
|
||||
<script>
|
||||
window.addEventListener('load', () => {
|
||||
navigator.serviceWorker.register('/sw.js?v1')
|
||||
navigator.serviceWorker.register('/sw.js?v2')
|
||||
})
|
||||
</script>
|
||||
{% for link in links %}
|
||||
|
@ -63,12 +63,12 @@ class TextureControllerTest extends TestCase
|
||||
$this->get('/preview/'.$skin->tid)->assertNotFound();
|
||||
|
||||
$disk->put($skin->hash, '');
|
||||
$this->get('/preview/'.$skin->tid)->assertHeader('Content-Type', 'image/png');
|
||||
$this->get('/preview/'.$skin->tid)->assertHeader('Content-Type', 'image/webp');
|
||||
$this->assertTrue(Cache::has('preview-t'.$skin->tid));
|
||||
|
||||
$cape = factory(Texture::class)->states('cape')->create();
|
||||
$disk->put($cape->hash, '');
|
||||
$this->get('/preview/'.$cape->tid.'?height=100')->assertHeader('Content-Type', 'image/png');
|
||||
$this->get('/preview/'.$cape->tid.'?height=100')->assertHeader('Content-Type', 'image/webp');
|
||||
$this->assertTrue(Cache::has('preview-t'.$cape->tid));
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ class TextureControllerTest extends TestCase
|
||||
$player = factory(Player::class)->create();
|
||||
$this->get('/avatar/player/'.$player->name)
|
||||
->assertSuccessful()
|
||||
->assertHeader('Content-Type', 'image/png');
|
||||
->assertHeader('Content-Type', 'image/webp');
|
||||
|
||||
$texture = factory(Texture::class)->create();
|
||||
$disk->put($texture->hash, '');
|
||||
@ -121,7 +121,7 @@ class TextureControllerTest extends TestCase
|
||||
$player->save();
|
||||
$image = $this->get('/avatar/player/'.$player->name)
|
||||
->assertSuccessful()
|
||||
->assertHeader('Content-Type', 'image/png')
|
||||
->assertHeader('Content-Type', 'image/webp')
|
||||
->getContent();
|
||||
$image = Image::make($image);
|
||||
$this->assertEquals(100, $image->width());
|
||||
@ -139,12 +139,12 @@ class TextureControllerTest extends TestCase
|
||||
|
||||
$this->get('/avatar/user/0')
|
||||
->assertSuccessful()
|
||||
->assertHeader('Content-Type', 'image/png');
|
||||
->assertHeader('Content-Type', 'image/webp');
|
||||
|
||||
$user = factory(User::class)->create();
|
||||
$this->get('/avatar/user/'.$user->uid)
|
||||
->assertSuccessful()
|
||||
->assertHeader('Content-Type', 'image/png');
|
||||
->assertHeader('Content-Type', 'image/webp');
|
||||
|
||||
$texture = factory(Texture::class)->create();
|
||||
$disk->put($texture->hash, '');
|
||||
@ -152,7 +152,7 @@ class TextureControllerTest extends TestCase
|
||||
$user->save();
|
||||
$image = $this->get('/avatar/user/'.$user->uid)
|
||||
->assertSuccessful()
|
||||
->assertHeader('Content-Type', 'image/png')
|
||||
->assertHeader('Content-Type', 'image/webp')
|
||||
->getContent();
|
||||
$image = Image::make($image);
|
||||
$this->assertEquals(100, $image->width());
|
||||
@ -170,7 +170,7 @@ class TextureControllerTest extends TestCase
|
||||
|
||||
$image = $this->get('/avatar/0')
|
||||
->assertSuccessful()
|
||||
->assertHeader('Content-Type', 'image/png')
|
||||
->assertHeader('Content-Type', 'image/webp')
|
||||
->getContent();
|
||||
$image = Image::make($image);
|
||||
$this->assertEquals(100, $image->width());
|
||||
@ -179,7 +179,7 @@ class TextureControllerTest extends TestCase
|
||||
$texture = factory(Texture::class)->create();
|
||||
$image = $this->get('/avatar/'.$texture->tid)
|
||||
->assertSuccessful()
|
||||
->assertHeader('Content-Type', 'image/png')
|
||||
->assertHeader('Content-Type', 'image/webp')
|
||||
->getContent();
|
||||
$image = Image::make($image);
|
||||
$this->assertEquals(100, $image->width());
|
||||
@ -188,7 +188,7 @@ class TextureControllerTest extends TestCase
|
||||
$disk->put($texture->hash, '');
|
||||
$image = $this->get('/avatar/'.$texture->tid)
|
||||
->assertSuccessful()
|
||||
->assertHeader('Content-Type', 'image/png')
|
||||
->assertHeader('Content-Type', 'image/webp')
|
||||
->getContent();
|
||||
$image = Image::make($image);
|
||||
$this->assertEquals(100, $image->width());
|
||||
@ -203,7 +203,7 @@ class TextureControllerTest extends TestCase
|
||||
|
||||
$image = $this->get('/avatar/'.$texture->tid.'?3d')
|
||||
->assertSuccessful()
|
||||
->assertHeader('Content-Type', 'image/png')
|
||||
->assertHeader('Content-Type', 'image/webp')
|
||||
->getContent();
|
||||
$image = Image::make($image);
|
||||
$this->assertEquals(100, $image->width());
|
||||
|
Loading…
Reference in New Issue
Block a user