66 if ($this->onlineMediaHelper ===
null) {
69 $orgFile = $orgFile->getOriginalFile();
71 if ($orgFile instanceof
File) {
74 $this->onlineMediaHelper =
false;
90 public function render(
FileInterface $file, $width, $height, array $options = [], $usedPathsRelativeToCurrentScript =
false)
97 '<iframe src="%s"%s></iframe>',
98 htmlspecialchars($src, ENT_QUOTES | ENT_HTML5),
111 if (!isset($options[
'autoplay']) && $file instanceof
FileReference) {
113 if ($autoplay !==
null) {
114 $options[
'autoplay'] = $autoplay;
118 $showPlayerControls = 1;
119 $options[
'controls'] = (int)!empty($options[
'controls'] ?? $showPlayerControls);
121 if (!isset($options[
'allow'])) {
122 $options[
'allow'] =
'fullscreen';
123 if (!empty($options[
'autoplay'])) {
124 $options[
'allow'] =
'autoplay; fullscreen';
139 $urlParams = [
'autohide=1'];
140 $urlParams[] =
'controls=' . $options[
'controls'];
141 if (!empty($options[
'autoplay'])) {
142 $urlParams[] =
'autoplay=1';
144 if (!empty($options[
'modestbranding'])) {
145 $urlParams[] =
'modestbranding=1';
147 if (!empty($options[
'loop'])) {
148 $urlParams[] =
'loop=1&playlist=' . rawurlencode($videoId);
150 if (isset($options[
'relatedVideos'])) {
151 $urlParams[] =
'rel=' . (int)(
bool)$options[
'relatedVideos'];
153 if (!isset($options[
'enablejsapi']) || !empty($options[
'enablejsapi'])) {
154 $urlParams[] =
'enablejsapi=1&origin=' . rawurlencode(GeneralUtility::getIndpEnv(
'TYPO3_REQUEST_HOST'));
157 $youTubeUrl = sprintf(
158 'https://www.youtube%s.com/embed/%s?%s',
159 !isset($options[
'no-cookie']) || !empty($options[
'no-cookie']) ?
'-nocookie' :
'',
160 rawurlencode($videoId),
161 implode(
'&', $urlParams)
174 $orgFile = $file->getOriginalFile();
191 $attributes[
'allowfullscreen'] =
true;
193 if (isset($options[
'additionalAttributes']) && is_array($options[
'additionalAttributes'])) {
194 $attributes = array_merge($attributes, $options[
'additionalAttributes']);
196 if (isset($options[
'data']) && is_array($options[
'data'])) {
197 array_walk($options[
'data'],
function (&$value, $key) use (&$attributes) {
198 $attributes[
'data-' . $key] = $value;
201 if ((
int)$width > 0) {
202 $attributes[
'width'] = (int)$width;
204 if ((
int)$height > 0) {
205 $attributes[
'height'] = (int)$height;
207 if (isset(
$GLOBALS[
'TSFE']) && is_object(
$GLOBALS[
'TSFE']) && (isset(
$GLOBALS[
'TSFE']->config[
'config'][
'doctype']) &&
$GLOBALS[
'TSFE']->config[
'config'][
'doctype'] !==
'html5')) {
208 $attributes[
'frameborder'] = 0;
210 foreach ([
'class',
'dir',
'id',
'lang',
'style',
'title',
'accesskey',
'tabindex',
'onclick',
'poster',
'preload',
'allow'] as $key) {
211 if (!empty($options[$key])) {
212 $attributes[$key] = $options[$key];
227 foreach ($attributes as $name => $value) {
228 $name = preg_replace(
'/[^\p{L}0-9_.-]/u',
'', $name);
229 if ($value ===
true) {
230 $attributeList[] = $name;
232 $attributeList[] = $name .
'="' . htmlspecialchars($value, ENT_QUOTES | ENT_HTML5) .
'"';
235 return implode(
' ', $attributeList);