diff --git a/app/Controllers/UploadController.php b/app/Controllers/UploadController.php index bb46e8cdb5d387733bf0425803f27b6a33465376..e43971cdcbf6347a148ac64791eb65dc10737def 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 84aa0d5b9e2cdc694292441edf82dfbe1d8601d4..7c332d098b9a1aa21d027bbf4583e5aa7238e621 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 41e4d540dd3926fe2fcebe404ba3807f02dadc84..94b24fae8ec42b03ead13e113da5d20379be3cd9 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 7c69cd790c6c078d138c4a5ea4d2f5f1a6787a1b..9d3d592c1c474daff1517db88b29c16f5e4e08eb 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;