From d4e020719a89d012670fe1be1d6b97040798225a Mon Sep 17 00:00:00 2001 From: Ivo Valchev Date: Fri, 16 Oct 2020 10:44:33 +0200 Subject: [PATCH 1/2] Configurable thumbnailing option --- config/config.yaml | 2 ++ src/Controller/Upload.php | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/config/config.yaml b/config/config.yaml index 7779cb0..c1a9e23 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -1,5 +1,7 @@ # Settings for Bolt Article +thumbnail: 1000×1000×max + # All options: blockcode, buttonlink, definedlinks, handle, inlineformat, icons, specialchars, reorder, print, selector, style, tags, underline, variable default: plugins: [ blockcode, buttonlink, definedlinks, inlineformat, reorder, tags, underline ] diff --git a/src/Controller/Upload.php b/src/Controller/Upload.php index a0b8598..8ce753a 100644 --- a/src/Controller/Upload.php +++ b/src/Controller/Upload.php @@ -102,9 +102,12 @@ public function handleUpload(Request $request): JsonResponse } if ($result->isValid()) { + + $thumbnail = '/thumbs/' . $this->config->get('thumbnail', '1000×1000×max') . '/'; + $resultMessage = [ 'filekey' => [ - 'url' => '/thumbs/1000×1000×max/' . $result->name, + 'url' => $thumbnail . $result->name, 'id' => 1, ], ]; From 465a15d4c752066004deaed6daa1d8511cb500d5 Mon Sep 17 00:00:00 2001 From: Ivo Valchev Date: Fri, 16 Oct 2020 10:59:30 +0200 Subject: [PATCH 2/2] Use proper config option default. --- config/config.yaml | 4 ++-- src/ArticleConfig.php | 1 + src/Controller/Upload.php | 10 +++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index c1a9e23..5d189dd 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -1,7 +1,5 @@ # Settings for Bolt Article -thumbnail: 1000×1000×max - # All options: blockcode, buttonlink, definedlinks, handle, inlineformat, icons, specialchars, reorder, print, selector, style, tags, underline, variable default: plugins: [ blockcode, buttonlink, definedlinks, inlineformat, reorder, tags, underline ] @@ -14,6 +12,8 @@ default: '4|8': 'col-4|col-8' '6|6': 'col-6|col-6' '8|4': 'col-8|col-4' + image: + thumbnail: 1000×1000×max plugins: ~ diff --git a/src/ArticleConfig.php b/src/ArticleConfig.php index 77a6070..448032d 100644 --- a/src/ArticleConfig.php +++ b/src/ArticleConfig.php @@ -70,6 +70,7 @@ private function getDefaults(): array '_csrf_token' => $this->csrfTokenManager->getToken('bolt_article')->getValue(), ], 'multiple' => false, + 'thumbnail' => '1000×1000×max', ], 'minHeight' => '200px', 'maxHeight' => '700px', diff --git a/src/Controller/Upload.php b/src/Controller/Upload.php index 8ce753a..2a9f086 100644 --- a/src/Controller/Upload.php +++ b/src/Controller/Upload.php @@ -4,6 +4,7 @@ namespace Bolt\Article\Controller; +use Bolt\Article\ArticleConfig; use Bolt\Configuration\Config; use Bolt\Controller\Backend\Async\AsyncZoneInterface; use Bolt\Controller\CsrfTrait; @@ -37,12 +38,16 @@ class Upload implements AsyncZoneInterface /** @var Request */ private $request; - public function __construct(Config $config, CsrfTokenManagerInterface $csrfTokenManager, TextExtension $textExtension, RequestStack $requestStack) + /** @var ArticleConfig */ + private $articleConfig; + + public function __construct(Config $config, CsrfTokenManagerInterface $csrfTokenManager, TextExtension $textExtension, RequestStack $requestStack, ArticleConfig $articleConfig) { $this->config = $config; $this->csrfTokenManager = $csrfTokenManager; $this->textExtension = $textExtension; $this->request = $requestStack->getCurrentRequest(); + $this->articleConfig = $articleConfig; } /** @@ -102,8 +107,7 @@ public function handleUpload(Request $request): JsonResponse } if ($result->isValid()) { - - $thumbnail = '/thumbs/' . $this->config->get('thumbnail', '1000×1000×max') . '/'; + $thumbnail = '/thumbs/' . $this->articleConfig->getConfig()['image']['thumbnail'] . '/'; $resultMessage = [ 'filekey' => [