fixed avatar can't be resized
when requesting an non-existed user
This commit is contained in:
parent
8703495f8f
commit
9988520f45
|
|
@ -13,6 +13,7 @@ use Carbon\Carbon;
|
|||
use Event;
|
||||
use Exception;
|
||||
use Illuminate\Support\Arr;
|
||||
use Image;
|
||||
use Option;
|
||||
use Response;
|
||||
use Storage;
|
||||
|
|
@ -75,7 +76,9 @@ class TextureController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
return response()->file(storage_path('static_textures/avatar.png'));
|
||||
$default = Image::make(storage_path('static_textures/avatar.png'));
|
||||
|
||||
return $default->resize($size, $size)->response();
|
||||
}
|
||||
|
||||
public function avatar($uid, $size = 128)
|
||||
|
|
@ -86,7 +89,9 @@ class TextureController extends Controller
|
|||
return $this->avatarByTid($user->avatar, $size);
|
||||
}
|
||||
|
||||
return response()->file(storage_path('static_textures/avatar.png'));
|
||||
$default = Image::make(storage_path('static_textures/avatar.png'));
|
||||
|
||||
return $default->resize($size, $size)->response();
|
||||
}
|
||||
|
||||
public function preview($tid, $size = 250)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
"facade/ignition": "^1.4",
|
||||
"gregwar/captcha": "1.*",
|
||||
"guzzlehttp/guzzle": "^6.3",
|
||||
"intervention/image": "^2.5",
|
||||
"laravel/framework": "6.*",
|
||||
"laravel/passport": "^7.3",
|
||||
"nesbot/carbon": "^2.0",
|
||||
|
|
|
|||
72
composer.lock
generated
72
composer.lock
generated
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "c3d467162ff1f1968385ca93b9f2ab24",
|
||||
"content-hash": "7fffc88319cd5ed6dbadbf6b52564465",
|
||||
"packages": [
|
||||
{
|
||||
"name": "blessing/filter",
|
||||
|
|
@ -1333,6 +1333,76 @@
|
|||
],
|
||||
"time": "2019-07-01T23:21:34+00:00"
|
||||
},
|
||||
{
|
||||
"name": "intervention/image",
|
||||
"version": "2.5.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Intervention/image.git",
|
||||
"reference": "abbf18d5ab8367f96b3205ca3c89fb2fa598c69e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Intervention/image/zipball/abbf18d5ab8367f96b3205ca3c89fb2fa598c69e",
|
||||
"reference": "abbf18d5ab8367f96b3205ca3c89fb2fa598c69e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-fileinfo": "*",
|
||||
"guzzlehttp/psr7": "~1.1",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~0.9.2",
|
||||
"phpunit/phpunit": "^4.8 || ^5.7"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-gd": "to use GD library based image processing.",
|
||||
"ext-imagick": "to use Imagick based image processing.",
|
||||
"intervention/imagecache": "Caching extension for the Intervention Image library"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
},
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Intervention\\Image\\ImageServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"Image": "Intervention\\Image\\Facades\\Image"
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Intervention\\Image\\": "src/Intervention/Image"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Oliver Vogel",
|
||||
"email": "oliver@olivervogel.com",
|
||||
"homepage": "http://olivervogel.com/"
|
||||
}
|
||||
],
|
||||
"description": "Image handling and manipulation library with support for Laravel integration",
|
||||
"homepage": "http://image.intervention.io/",
|
||||
"keywords": [
|
||||
"gd",
|
||||
"image",
|
||||
"imagick",
|
||||
"laravel",
|
||||
"thumbnail",
|
||||
"watermark"
|
||||
],
|
||||
"time": "2019-11-02T09:15:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"version": "v6.9.0",
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
- Fixed that dependencies and conflicts haven't been checked before installing plugin.
|
||||
- Fixed retrieving search keyword from query string in skin library.
|
||||
- Fixed that `lang` attribute of HTML can't be configured correctly.
|
||||
- Fixed that avatar can't be resized when requesting an non-existed user.
|
||||
|
||||
## Removed
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
- 下载插件前不检查依赖和冲突的问题
|
||||
- 修复皮肤库中从 query string 获取搜索关键字的问题
|
||||
- 修复未能正确设置 HTML 的 `lang` 属性的问题
|
||||
- 修复获取不存在的用户的头像时,未能正确设置尺寸的问题
|
||||
|
||||
## 移除
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use Event;
|
|||
use Exception;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Image;
|
||||
use Mockery;
|
||||
|
||||
class TextureControllerTest extends TestCase
|
||||
|
|
@ -105,7 +106,12 @@ class TextureControllerTest extends TestCase
|
|||
Event::fake();
|
||||
|
||||
Storage::fake('textures');
|
||||
$this->get('/avatar/user/5')->assertHeader('Content-Type', 'image/png');
|
||||
$image = $this->get('/avatar/user/5/45')
|
||||
->assertHeader('Content-Type', 'image/png')
|
||||
->getContent();
|
||||
$image = Image::make($image);
|
||||
$this->assertEquals(45, $image->width());
|
||||
$this->assertEquals(45, $image->height());
|
||||
|
||||
$steve = factory(Texture::class)->create();
|
||||
$png = base64_decode(\App\Http\Controllers\TextureController::getDefaultSteveSkin());
|
||||
|
|
@ -123,8 +129,12 @@ class TextureControllerTest extends TestCase
|
|||
Event::assertDispatched(\App\Events\GetAvatarPreview::class);
|
||||
|
||||
Storage::shouldReceive('disk')->with('textures')->andThrow(new Exception());
|
||||
$this->get('/avatar/user/'.$user->uid.'/45')
|
||||
->assertHeader('Content-Type', 'image/png');
|
||||
$image = $this->get('/avatar/user/'.$user->uid.'/45')
|
||||
->assertHeader('Content-Type', 'image/png')
|
||||
->getContent();
|
||||
$image = Image::make($image);
|
||||
$this->assertEquals(45, $image->width());
|
||||
$this->assertEquals(45, $image->height());
|
||||
}
|
||||
|
||||
public function testPreview()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user