Block Vimeo (or Youtube) in Textmedia
29. November 2022
29. November 2022
External videos from youtube or vimeo should be blocked until consent is given. In the textmedia element this is not given out of the box, but we can override the renderer:
$rendererRegistry = \TYPO3\CMS\Core\Resource\Rendering\RendererRegistry::getInstance(); $rendererRegistry->registerRendererClass(\Vendo\Extension\Resource\Rendering\VimeoRenderer::class);
<?php
namespace EJSA\ZwbisdreiConfig\Resource\Rendering;
use TYPO3\CMS\Core\Resource\FileInterface;
class VimeoRenderer extends \TYPO3\CMS\Core\Resource\Rendering\VimeoRenderer
{
public function getPriority(): int
{
return 25;
}
public function render(FileInterface $file, $width, $height, array $options = [], $usedPathsRelativeToCurrentScript = false)
{
$options = $this->collectOptions($options, $file);
return str_replace(' src="', ' src="about:blank" data-cmp-vendor="c77" class="cmplazyload" data-cmp-src="', parent::render($file, $width, $height, $options, $usedPathsRelativeToCurrentScript));
}
}