diff --git a/app/Controllers/UploadController.php b/app/Controllers/UploadController.php index bb46e8c..e43971c 100644 --- a/app/Controllers/UploadController.php +++ b/app/Controllers/UploadController.php @@ -3,6 +3,7 @@ namespace App\Controllers; use GuzzleHttp\Psr7\Stream; +use Intervention\Image\Constraint; use Intervention\Image\ImageManagerStatic as Image; use League\Flysystem\FileExistsException; use League\Flysystem\FileNotFoundException; @@ -378,16 +379,20 @@ class UploadController extends Controller if (param($request, 'width') !== null && explode('/', $mime)[0] === 'image') { $image = Image::make($storage->readStream($media->storage_path)) - ->resizeCanvas( + ->resize( param($request, 'width'), param($request, 'height'), - 'center') - ->encode('png'); + function (Constraint $constraint) { + $constraint->aspectRatio(); + }) + ->resizeCanvas(param($request, 'width'), + param($request, 'height'), 'center') + ->stream('png'); - $response->getBody()->write($image); return $response ->withHeader('Content-Type', 'image/png') - ->withHeader('Content-Disposition', $disposition.';filename="scaled-'.pathinfo($media->filename)['filename'].'.png"'); + ->withHeader('Content-Disposition', $disposition.';filename="scaled-'.pathinfo($media->filename, PATHINFO_FILENAME).'.png"') + ->withBody($image); } else { $stream = new Stream($storage->readStream($media->storage_path)); diff --git a/resources/templates/dashboard/grid.twig b/resources/templates/dashboard/grid.twig index 84aa0d5..7c332d0 100644 --- a/resources/templates/dashboard/grid.twig +++ b/resources/templates/dashboard/grid.twig @@ -13,7 +13,7 @@
{% if isDisplayableImage(media.mimetype) %} - Card image + Card image {% else %}
{% endif %} diff --git a/resources/templates/dashboard/list.twig b/resources/templates/dashboard/list.twig index 41e4d54..94b24fa 100644 --- a/resources/templates/dashboard/list.twig +++ b/resources/templates/dashboard/list.twig @@ -32,9 +32,9 @@ {% if isDisplayableImage(media.mimetype) %} {% if media.username is not null %} - + {% else %} - + {% endif %} {% else %} diff --git a/src/css/app.css b/src/css/app.css index 7c69cd7..9d3d592 100644 --- a/src/css/app.css +++ b/src/css/app.css @@ -40,10 +40,6 @@ body { border-top-right-radius: 0; } -.admin-img { - max-height: 25px; -} - .user-title { white-space: nowrap; overflow: hidden;