Skip to content

Commit 73efbec

Browse files
authored
Merge pull request #6 from bolt/feature/configure-image-thumbnailing
Allow thumbnailing images to be configured
2 parents c9b71c2 + dd494af commit 73efbec

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

config/config.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ default:
55
buttons: [ bold, italic, format, lists, link, html, image ]
66
plugins: [ fullscreen, table, inlinestyle, video, widget ]
77
source: true
8+
image:
9+
thumbnail: 1000×1000×max
810

911
plugins:
1012
~

src/Controller/Upload.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Bolt\Configuration\Config;
88
use Bolt\Controller\Backend\Async\AsyncZoneInterface;
99
use Bolt\Controller\CsrfTrait;
10+
use Bolt\Redactor\RedactorConfig;
1011
use Bolt\Twig\TextExtension;
1112
use Cocur\Slugify\Slugify;
1213
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
@@ -37,12 +38,16 @@ class Upload implements AsyncZoneInterface
3738
/** @var Request */
3839
private $request;
3940

40-
public function __construct(Config $config, CsrfTokenManagerInterface $csrfTokenManager, TextExtension $textExtension, RequestStack $requestStack)
41+
/** @var RedactorConfig */
42+
private $redactorConfig;
43+
44+
public function __construct(Config $config, CsrfTokenManagerInterface $csrfTokenManager, TextExtension $textExtension, RequestStack $requestStack, RedactorConfig $redactorConfig)
4145
{
4246
$this->config = $config;
4347
$this->csrfTokenManager = $csrfTokenManager;
4448
$this->textExtension = $textExtension;
4549
$this->request = $requestStack->getCurrentRequest();
50+
$this->redactorConfig = $redactorConfig;
4651
}
4752

4853
/**
@@ -102,9 +107,11 @@ public function handleUpload(Request $request): JsonResponse
102107
}
103108

104109
if ($result->isValid()) {
110+
$thumbnail = '/thumbs/' . $this->redactorConfig->getConfig()['image']['thumbnail'] . '/';
111+
105112
$resultMessage = [
106113
'filekey' => [
107-
'url' => '/thumbs/1000×1000×max/' . $result->name,
114+
'url' => $thumbnail . $result->name,
108115
'id' => 1,
109116
],
110117
];

0 commit comments

Comments
 (0)