Commit 67ee9a95 authored by Tino Goratsch's avatar Tino Goratsch

added a new "absolute" flag to the "image" function so that it outputs absolute URLs

parent 3846b064
......@@ -10,6 +10,7 @@ namespace ACP3\Core\View\Renderer\Smarty\Functions;
use ACP3\Core\Application\BootstrapInterface;
use ACP3\Core\Assets\FileResolver;
use ACP3\Core\Environment\ApplicationPath;
use ACP3\Core\Http\RequestInterface;
class Image extends AbstractFunction
{
......@@ -21,16 +22,22 @@ class Image extends AbstractFunction
* @var ApplicationPath
*/
private $appPath;
/**
* @var RequestInterface
*/
private $request;
/**
* Image constructor.
* @param RequestInterface $request
* @param FileResolver $fileResolver
* @param ApplicationPath $appPath
*/
public function __construct(FileResolver $fileResolver, ApplicationPath $appPath)
public function __construct(RequestInterface $request, FileResolver $fileResolver, ApplicationPath $appPath)
{
$this->fileResolver = $fileResolver;
$this->appPath = $appPath;
$this->request = $request;
}
/**
......@@ -49,6 +56,10 @@ class Image extends AbstractFunction
$path = $this->appPath->getWebRoot() . substr($path, strlen(ACP3_ROOT_DIR));
}
if (isset($params['absolute']) && $params['absolute'] === true) {
$path = $this->request->getScheme() . '://' . $this->request->getHttpHost() . $path;
}
return $path . '?v=' . BootstrapInterface::VERSION;
}
......
......@@ -43,7 +43,10 @@ services:
smarty.plugin.image:
class: ACP3\Core\View\Renderer\Smarty\Functions\Image
arguments: ['@core.assets.file_resolver', '@core.environment.application_path']
arguments:
- '@core.http.request'
- '@core.assets.file_resolver'
- '@core.environment.application_path'
tags:
- { name: core.view.extension }
......
......@@ -45,6 +45,9 @@
width: 600px;
margin: 0 auto;
}
.logo {
height: 89px;
}
.text-left {
text-align: left;
}
......@@ -69,7 +72,14 @@
{/if}
{/block}
<center>
<table class="email-content-wrapper">
<table border="0" cellpadding="0" cellspacing="0" class="email-content-wrapper">
<tr>
<td class="text-center">
{block EMAIL_HEADER}
<img src="{image file="logo.png" absolute=true}" alt="{site_title}" class="logo">
{/block}
</td>
</tr>
<tr>
<td>
{block EMAIL_CONTENT}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment