瀏覽代碼

Avoid response-copying when resizing images.

Sergio Brighenti 5 年之前
父節點
當前提交
d7a78a0201
共有 3 個文件被更改,包括 22 次插入8 次删除
  1. 3 6
      app/Controllers/UploadController.php
  2. 2 0
      resources/lang/en.lang.php
  3. 17 2
      resources/templates/dashboard/system.twig

+ 3 - 6
app/Controllers/UploadController.php

@@ -379,7 +379,7 @@ class UploadController extends Controller
 
 
         if (param($request, 'width') !== null && explode('/', $mime)[0] === 'image') {
         if (param($request, 'width') !== null && explode('/', $mime)[0] === 'image') {
 
 
-            $image = Image::make($storage->readStream($media->storage_path))
+            $response = Image::make($storage->readStream($media->storage_path))
                 ->resize(
                 ->resize(
                     param($request, 'width'),
                     param($request, 'width'),
                     param($request, 'height'),
                     param($request, 'height'),
@@ -388,12 +388,9 @@ class UploadController extends Controller
                     })
                     })
                 ->resizeCanvas(param($request, 'width'),
                 ->resizeCanvas(param($request, 'width'),
                     param($request, 'height'), 'center')
                     param($request, 'height'), 'center')
-                ->stream('png');
+                ->psrResponse('png');
 
 
-            return $response
-                ->withHeader('Content-Type', 'image/png')
-                ->withHeader('Content-Disposition', $disposition.';filename="scaled-'.pathinfo($media->filename, PATHINFO_FILENAME).'.png"')
-                ->withBody($image);
+            return $response->withHeader('Content-Disposition', $disposition.';filename="scaled-'.pathinfo($media->filename, PATHINFO_FILENAME).'.png"');
         } else {
         } else {
             $stream = new Stream($storage->readStream($media->storage_path));
             $stream = new Stream($storage->readStream($media->storage_path));
 
 

+ 2 - 0
resources/lang/en.lang.php

@@ -108,4 +108,6 @@ return [
     'custom_head_html_hint' => 'This content will be added at the <head> tag on every page.',
     'custom_head_html_hint' => 'This content will be added at the <head> tag on every page.',
     'custom_head_set' => 'Custom Head HTML applied successfully.',
     'custom_head_set' => 'Custom Head HTML applied successfully.',
     'remember_me' => 'Remember me',
     'remember_me' => 'Remember me',
+    'please_wait' => 'Please wait...',
+    'dont_close' => 'Do not close this tab until completion.',
 ];
 ];

+ 17 - 2
resources/templates/dashboard/system.twig

@@ -78,7 +78,7 @@
                             </div>
                             </div>
                         </div>
                         </div>
                     </div>
                     </div>
-                    <div class="col-md-6">
+                    <div class="col-md-6 mt-3">
                         <div class="card shadow-sm same-height">
                         <div class="card shadow-sm same-height">
                             <div class="card-header"><i class="fas fa-language fa-fw"></i> {{ lang('enforce_language') }}</div>
                             <div class="card-header"><i class="fas fa-language fa-fw"></i> {{ lang('enforce_language') }}</div>
                             <div class="card-body">
                             <div class="card-body">
@@ -125,7 +125,7 @@
 
 
                             <div class="col">
                             <div class="col">
                                 <form method="post" action="{{ route('system.upgrade') }}">
                                 <form method="post" action="{{ route('system.upgrade') }}">
-                                    <button type="submit" id="doUpgradeButton" class="btn btn-block btn-outline-success" disabled><i class="fas fa-cloud-download-alt fa-fw"></i> {{ lang('upgrade') }}</button>
+                                    <button type="submit" id="doUpgradeButton" class="btn btn-block btn-outline-success" onsubmit="$('#modalLoading').modal({backdrop: 'static', keyboard: false})" disabled><i class="fas fa-cloud-download-alt fa-fw"></i> {{ lang('upgrade') }}</button>
                                 </form>
                                 </form>
                             </div>
                             </div>
                         </div>
                         </div>
@@ -173,4 +173,19 @@
             </div>
             </div>
         </div>
         </div>
     </div>
     </div>
+    <div class="modal fade" id="modalLoading" tabindex="-1" role="dialog" aria-hidden="true">
+        <div class="modal-dialog modal-sm">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h6 class="modal-title">{{ lang('please_wait') }}</h6>
+                </div>
+                <div class="modal-body text-center">
+                    <i class="fas fa-10x fa-spinner fa-pulse"></i>
+                </div>
+                <div class="modal-footer">
+                    {{ lang('dont_close') }}
+                </div>
+            </div>
+        </div>
+    </div>
 {% endblock %}
 {% endblock %}