]> BookStack Code Mirror - bookstack/commitdiff
Updated secure-images option to not effect image name
authorDan Brown <redacted>
Sun, 20 May 2018 15:47:53 +0000 (16:47 +0100)
committerDan Brown <redacted>
Sun, 20 May 2018 15:47:53 +0000 (16:47 +0100)
Instead only the image path is altered.
Also fixed image manger mode not changing on button press.

app/Services/ImageService.php
resources/assets/js/components/wysiwyg-editor.js

index 736b30705ccd99bf24ffc9bed601d2fc1d62d554..c087c1e03221f037df53219479345f5184ae51a8 100644 (file)
@@ -114,16 +114,16 @@ class ImageService extends UploadService
         $secureUploads = setting('app-secure-images');
         $imageName = str_replace(' ', '-', $imageName);
 
-        if ($secureUploads) {
-            $imageName = str_random(16) . '-' . $imageName;
-        }
-
         $imagePath = '/uploads/images/' . $type . '/' . Date('Y-m-M') . '/';
 
         while ($storage->exists($imagePath . $imageName)) {
             $imageName = str_random(3) . $imageName;
         }
+
         $fullPath = $imagePath . $imageName;
+        if ($secureUploads) {
+            $fullPath = $imagePath . str_random(16) . '-' . $imageName;
+        }
 
         try {
             $storage->put($fullPath, $imageData);
index 764b0a929ff6a2f3b38b4462e651a7009d6e54e5..72263e2f271452e445a4340cef8b34544c6c3f2a 100644 (file)
@@ -547,7 +547,7 @@ class WysiwygEditor {
                             html += `<img src="${image.thumbs.display}" alt="${image.name}">`;
                             html += '</a>';
                             editor.execCommand('mceInsertContent', false, html);
-                        });
+                        }, 'gallery');
                     }
                 });