Commit bb32a77c authored by Oliver Bartsch's avatar Oliver Bartsch Committed by Benni Mack

[BUGFIX] Use absolute path for media files in backend

Since #93048 using relative paths in backend does not
longer work in most cases. Therefore the MediaRenderers
should always use absoulte paths when in backend context.

Resolves: #93226
Releases: master
Change-Id: Iad08c8a4b8e255c67b6bb6fe168ecc4915620d35
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67357Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarGuido Schmechel <guido.schmechel@brandung.de>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarGuido Schmechel <guido.schmechel@brandung.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent d3e5dc32
......@@ -318,14 +318,7 @@ class ElementInformationController
// Check if there is a FileRenderer
if ($fileRenderer !== null) {
$preview['fileRenderer'] = $fileRenderer->render(
$this->fileObject,
$width,
$height,
[],
true
);
$preview['fileRenderer'] = $fileRenderer->render($this->fileObject, $width, $height);
// else check if we can create an Image preview
} elseif ($this->fileObject->isImage()) {
$preview['fileObject'] = $this->fileObject;
......
......@@ -15,9 +15,12 @@
namespace TYPO3\CMS\Core\Resource\Rendering;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Http\ApplicationType;
use TYPO3\CMS\Core\Resource\FileInterface;
use TYPO3\CMS\Core\Resource\FileReference;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
/**
* Class AudioTagRenderer
......@@ -108,8 +111,22 @@ class AudioTagRenderer implements FileRendererInterface
return sprintf(
'<audio%s><source src="%s" type="%s"></audio>',
empty($additionalAttributes) ? '' : ' ' . implode(' ', $additionalAttributes),
htmlspecialchars((string)$file->getPublicUrl($usedPathsRelativeToCurrentScript)),
htmlspecialchars($this->getSource($file, $usedPathsRelativeToCurrentScript)),
$file->getMimeType()
);
}
protected function getSource(FileInterface $file, bool $usedPathsRelativeToCurrentScript): string
{
$source = (string)$file->getPublicUrl($usedPathsRelativeToCurrentScript);
// We need an absolute path for the backend
if (($GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface
&& ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend()
) {
$source = PathUtility::getAbsoluteWebPath($source);
}
return $source;
}
}
......@@ -15,9 +15,12 @@
namespace TYPO3\CMS\Core\Resource\Rendering;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Http\ApplicationType;
use TYPO3\CMS\Core\Resource\FileInterface;
use TYPO3\CMS\Core\Resource\FileReference;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
/**
* Class VideoTagRenderer
......@@ -125,8 +128,22 @@ class VideoTagRenderer implements FileRendererInterface
return sprintf(
'<video%s><source src="%s" type="%s"></video>',
empty($attributes) ? '' : ' ' . implode(' ', $attributes),
htmlspecialchars((string)$file->getPublicUrl($usedPathsRelativeToCurrentScript)),
htmlspecialchars($this->getSource($file, $usedPathsRelativeToCurrentScript)),
$file->getMimeType()
);
}
protected function getSource(FileInterface $file, bool $usedPathsRelativeToCurrentScript): string
{
$source = (string)$file->getPublicUrl($usedPathsRelativeToCurrentScript);
// We need an absolute path for the backend
if (($GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface
&& ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend()
) {
$source = PathUtility::getAbsoluteWebPath($source);
}
return $source;
}
}
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