diff --git a/src/Controller/MediaController.php b/src/Controller/MediaController.php index 78a91176b..3dd1e28bb 100755 --- a/src/Controller/MediaController.php +++ b/src/Controller/MediaController.php @@ -42,7 +42,7 @@ public function renderMediaAction(Request $request): Response $mediaProviderResolver = $this->get('bitbag_sylius_cms_plugin.resolver.media_provider'); - return new Response($mediaProviderResolver->resolveProvider($media)->render($media)); + return new Response($mediaProviderResolver->resolveProvider($media)->render($media, $request->get('template'))); } public function downloadMediaAction(Request $request): Response diff --git a/src/MediaProvider/GenericProvider.php b/src/MediaProvider/GenericProvider.php index 9dc970560..988cc61dd 100755 --- a/src/MediaProvider/GenericProvider.php +++ b/src/MediaProvider/GenericProvider.php @@ -47,9 +47,9 @@ public function getTemplate(): string return $this->template; } - public function render(MediaInterface $media, array $options = []): string + public function render(MediaInterface $media, ?string $template = null, array $options = []): string { - return $this->twigEngine->render($this->template, array_merge(['media' => $media], $options)); + return $this->twigEngine->render($template ?? $this->template, array_merge(['media' => $media], $options)); } public function upload(MediaInterface $media): void diff --git a/src/MediaProvider/ProviderInterface.php b/src/MediaProvider/ProviderInterface.php index 7cfa73170..c511305a9 100644 --- a/src/MediaProvider/ProviderInterface.php +++ b/src/MediaProvider/ProviderInterface.php @@ -18,7 +18,7 @@ interface ProviderInterface { public function getTemplate(): string; - public function render(MediaInterface $media, array $options = []): string; + public function render(MediaInterface $media, ?string $template = null, array $options = []): string; public function upload(MediaInterface $media): void; }