diff --git a/config/config.yaml b/config/config.yaml index 7779cb0..5d189dd 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -12,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 a0b8598..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,9 +107,11 @@ public function handleUpload(Request $request): JsonResponse } if ($result->isValid()) { + $thumbnail = '/thumbs/' . $this->articleConfig->getConfig()['image']['thumbnail'] . '/'; + $resultMessage = [ 'filekey' => [ - 'url' => '/thumbs/1000×1000×max/' . $result->name, + 'url' => $thumbnail . $result->name, 'id' => 1, ], ];