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 if (!isset($options[
'allow'])) {
119 $options[
'allow'] =
'fullscreen';
120 if (!empty($options[
'autoplay'])) {
121 $options[
'allow'] =
'autoplay; fullscreen';
138 if (!empty($options[
'autoplay'])) {
139 $urlParams[] =
'autoplay=1';
141 if (!empty($options[
'loop'])) {
142 $urlParams[] =
'loop=1';
144 if (!empty($options[
'no-cookie'])) {
145 $urlParams[] =
'dnt=1';
147 $urlParams[] =
'title=' . (int)!empty($options[
'showinfo']);
148 $urlParams[] =
'byline=' . (int)!empty($options[
'showinfo']);
149 $urlParams[] =
'portrait=0';
151 return sprintf(
'https://player.vimeo.com/video/%s?%s', $videoId, implode(
'&', $urlParams));
161 $orgFile = $file->getOriginalFile();
178 $attributes[
'allowfullscreen'] =
true;
180 if (isset($options[
'additionalAttributes']) && is_array($options[
'additionalAttributes'])) {
181 $attributes = array_merge($attributes, $options[
'additionalAttributes']);
183 if (isset($options[
'data']) && is_array($options[
'data'])) {
186 function (&$value, $key) use (&$attributes) {
187 $attributes[
'data-' . $key] = $value;
191 if ((
int)$width > 0) {
192 $attributes[
'width'] = (int)$width;
194 if ((
int)$height > 0) {
195 $attributes[
'height'] = (int)$height;
197 if (isset(
$GLOBALS[
'TSFE']) && is_object(
$GLOBALS[
'TSFE']) && (isset(
$GLOBALS[
'TSFE']->config[
'config'][
'doctype']) &&
$GLOBALS[
'TSFE']->config[
'config'][
'doctype'] !==
'html5')) {
198 $attributes[
'frameborder'] = 0;
200 foreach ([
'class',
'dir',
'id',
'lang',
'style',
'title',
'accesskey',
'tabindex',
'onclick',
'allow'] as $key) {
201 if (!empty($options[$key])) {
202 $attributes[$key] = $options[$key];
216 foreach ($attributes as $name => $value) {
217 $name = preg_replace(
'/[^\p{L}0-9_.-]/u',
'', $name);
218 if ($value ===
true) {
219 $attributeList[] = $name;
221 $attributeList[] = $name .
'="' . htmlspecialchars($value, ENT_QUOTES | ENT_HTML5) .
'"';
224 return implode(
' ', $attributeList);