Description
If you have a storage configured that generates urls for another host, these urls get prefixed with the current domain. For instance this happens with our AWS storage:
Website Domain: www.example.ch
Storage Url: example.ch.s3.amazonaws.com/example.png
Generated Image source: www.example.chexample.ch.s3.amazonaws.com/example.png
The problem is, that the following function always prepends $GLOBALS['TSFE']->absRefPrefix
even though its description states, that it would only do so if necessary.
https://github.com/FluidTYPO3/vhs/blob/development/Classes/ViewHelpers/Media/AbstractMediaViewHelper.php#L59-L68
In contrast to this the TYPO3 Core Fluid ViewHelper only prefixes the url if it is not already fully qualified.
See https://github.com/TYPO3-CMS/extbase/blob/master/Classes/Service/ImageService.php#L86-L93
One solution would be to implement a check similar to what TYPO3 Core does:
public static function preprocessSourceUri($src, array $arguments)
{
$parsedUrl = parse_url($src);
// no prefix in case of an already fully qualified URL
if (isset($parsedUrl['host'])) {
if (!isset($parsedUrl['scheme'])) {
$src = (GeneralUtility::getIndpEnv('TYPO3_SSL') ? 'https:' : 'http:') . $src;
}
} else {
$src = $GLOBALS['TSFE']->absRefPrefix . str_replace('%2F', '/', rawurlencode($src));
}
if (false === empty($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_vhs.']['settings.']['prependPath'])) {
$src = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_vhs.']['settings.']['prependPath'] . $src;
} elseif ('BE' === TYPO3_MODE || false === (boolean) $arguments['relative']) {
$src = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . ltrim($src, '/');
}
return $src;
}
What do you think? Are there other ways to fix this?
Activity