/**
  * Render for given File(Reference) html output
  *
  * @param FileInterface $file
  * @param int|string $width TYPO3 known format; examples: 220, 200m or 200c
  * @param int|string $height TYPO3 known format; examples: 220, 200m or 200c
  * @param array $options
  * @param bool $usedPathsRelativeToCurrentScript See $file->getPublicUrl()
  * @return string
  */
 public function render(FileInterface $file, $width, $height, array $options = null, $usedPathsRelativeToCurrentScript = false)
 {
     if ($file instanceof FileReference) {
         $autoplay = $file->getProperty('autoplay');
         if ($autoplay !== null) {
             $options['autoplay'] = $autoplay;
         }
     }
     $urlParams = array();
     if (!empty($options['autoplay'])) {
         $urlParams[] = 'autoplay=1';
     }
     if (!empty($options['loop'])) {
         $urlParams[] = 'loop=1';
     }
     $urlParams[] = 'title=' . (int) (!empty($options['showinfo']));
     $urlParams[] = 'byline=' . (int) (!empty($options['showinfo']));
     $urlParams[] = 'portrait=0';
     if ($file instanceof FileReference) {
         $orgFile = $file->getOriginalFile();
     } else {
         $orgFile = $file;
     }
     $videoId = $this->getOnlineMediaHelper($file)->getOnlineMediaId($orgFile);
     $src = sprintf('//player.vimeo.com/video/%s?%s', $videoId, implode('&', $urlParams));
     $attributes = array('allowfullscreen');
     if ((int) $width > 0) {
         $attributes[] = 'width="' . (int) $width . '"';
     }
     if ((int) $height > 0) {
         $attributes[] = 'height="' . (int) $height . '"';
     }
     if (is_object($GLOBALS['TSFE']) && $GLOBALS['TSFE']->config['config']['doctype'] !== 'html5') {
         $attributes[] = 'frameborder="0"';
     }
     foreach (array('class', 'dir', 'id', 'lang', 'style', 'title', 'accesskey', 'tabindex', 'onclick') as $key) {
         if (!empty($options[$key])) {
             $attributes[] = $key . '="' . htmlspecialchars($options[$key]) . '"';
         }
     }
     return sprintf('<iframe src="%s"%s></iframe>', $src, empty($attributes) ? '' : ' ' . implode(' ', $attributes));
 }
 /**
  * Render for given File(Reference) html output
  *
  * @param FileInterface $file
  * @param int|string $width TYPO3 known format; examples: 220, 200m or 200c
  * @param int|string $height TYPO3 known format; examples: 220, 200m or 200c
  * @param array $options
  * @param bool $usedPathsRelativeToCurrentScript See $file->getPublicUrl()
  * @return string
  */
 public function render(FileInterface $file, $width, $height, array $options = null, $usedPathsRelativeToCurrentScript = false)
 {
     if ($file instanceof FileReference) {
         $autoplay = $file->getProperty('autoplay');
         if ($autoplay !== null) {
             $options['autoplay'] = $autoplay;
         }
     }
     $urlParams = array();
     if (!empty($options['autoplay'])) {
         $urlParams[] = 'auto_play=1';
     }
     if ($file instanceof FileReference) {
         $orgFile = $file->getOriginalFile();
     } else {
         $orgFile = $file;
     }
     $soundCloudId = $this->getOnlineMediaHelper($file)->getOnlineMediaId($orgFile);
     $src = sprintf('//w.soundcloud.com/player/?url=%s?%s', urlencode('https://api.soundcloud.com/tracks/' . $soundCloudId), implode('&amp;', $urlParams));
     foreach (['class', 'dir', 'id', 'lang', 'style', 'title', 'accesskey', 'tabindex', 'onclick'] as $key) {
         if (!empty($options[$key])) {
             $attributes[] = $key . '="' . htmlspecialchars($options[$key]) . '"';
         }
     }
     return sprintf('<iframe src="%s"%s></iframe>', $src, empty($attributes) ? '' : ' ' . implode(' ', $attributes));
 }
 /**
  * @param FileInterface $file
  * @param int|string $width TYPO3 known format; examples: 220, 200m or 200c
  * @param int|string $height TYPO3 known format; examples: 220, 200m or 200c
  * @param array $options
  * @param bool $usedPathsRelativeToCurrentScript See $file->getPublicUrl()
  * @return string
  */
 public function render(FileInterface $file, $width, $height, array $options = array(), $usedPathsRelativeToCurrentScript = false)
 {
     $data = $srcset = $sizes = [];
     if ($file instanceof FileReference) {
         $originalFile = $file->getOriginalFile();
     } else {
         $originalFile = $file;
     }
     try {
         $defaultProcessConfiguration = [];
         $defaultProcessConfiguration['width'] = (int) $width;
         $defaultProcessConfiguration['crop'] = $file->getProperty('crop');
     } catch (\InvalidArgumentException $e) {
         $defaultProcessConfiguration['crop'] = '';
     }
     foreach ($this->settings['sourceCollection'] as $configuration) {
         try {
             if (!is_array($configuration)) {
                 throw new \RuntimeException();
             }
             if (isset($configuration['sizes'])) {
                 $sizes[] = trim($configuration['sizes'], ' ,');
             }
             if ((int) $configuration['width'] > (int) $width) {
                 throw new \RuntimeException();
             }
             $localProcessingConfiguration = $defaultProcessConfiguration;
             $localProcessingConfiguration['width'] = $configuration['width'];
             $processedFile = $originalFile->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $localProcessingConfiguration);
             $url = $this->absRefPrefix . $processedFile->getPublicUrl();
             $data['data-' . $configuration['dataKey']] = $url;
             $srcset[] = $url . rtrim(' ' . $configuration['srcset'] ?: '');
         } catch (\Exception $ignoredException) {
             continue;
         }
     }
     $src = $originalFile->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $defaultProcessConfiguration)->getPublicUrl();
     $this->tagBuilder->reset();
     $this->tagBuilder->setTagName('img');
     $this->tagBuilder->addAttribute('src', $src);
     $this->tagBuilder->addAttribute('alt', $file->getProperty('alternative'));
     $this->tagBuilder->addAttribute('title', $file->getProperty('title'));
     switch ($this->settings['layoutKey']) {
         case 'srcset':
             if (!empty($srcset)) {
                 $this->tagBuilder->addAttribute('srcset', implode(', ', $srcset));
             }
             $this->tagBuilder->addAttribute('sizes', implode(', ', $sizes));
             break;
         case 'data':
             if (!empty($data)) {
                 foreach ($data as $key => $value) {
                     $this->tagBuilder->addAttribute($key, $value);
                 }
             }
             break;
         default:
             $this->tagBuilder->addAttributes(['width' => (int) $width, 'height' => (int) $height]);
             break;
     }
     return $this->tagBuilder->render();
 }
 /**
  * Render for given File(Reference) html output
  *
  * @param FileInterface $file
  * @param int|string $width TYPO3 known format; examples: 220, 200m or 200c
  * @param int|string $height TYPO3 known format; examples: 220, 200m or 200c
  * @param array $options
  * @param bool $usedPathsRelativeToCurrentScript See $file->getPublicUrl()
  * @return string
  */
 public function render(FileInterface $file, $width, $height, array $options = null, $usedPathsRelativeToCurrentScript = false)
 {
     if ($file instanceof FileReference) {
         $autoplay = $file->getProperty('autoplay');
         if ($autoplay !== null) {
             $options['autoplay'] = $autoplay;
         }
     }
     $urlParams = array('autohide=1');
     if (!isset($options['controls']) || !empty($options['controls'])) {
         $urlParams[] = 'controls=2';
     }
     if (!empty($options['autoplay'])) {
         $urlParams[] = 'autoplay=1';
     }
     if (!empty($options['loop'])) {
         $urlParams[] = 'loop=1';
     }
     if (!isset($options['enablejsapi']) || !empty($options['enablejsapi'])) {
         $urlParams[] = 'enablejsapi=1&amp;origin=' . GeneralUtility::getIndpEnv('HTTP_HOST');
     }
     $urlParams[] = 'showinfo=' . (int) (!empty($options['showinfo']));
     if ($file instanceof FileReference) {
         $orgFile = $file->getOriginalFile();
     } else {
         $orgFile = $file;
     }
     $videoId = $this->getOnlineMediaHelper($file)->getOnlineMediaId($orgFile);
     $src = sprintf('//www.youtube%s.com/embed/%s?%s', !empty($options['no-cookie']) ? '-nocookie' : '', $videoId, implode('&amp;', $urlParams));
     $attributes = ['allowfullscreen'];
     if ((int) $width > 0) {
         $attributes[] = 'width="' . (int) $width . '"';
     }
     if ((int) $height > 0) {
         $attributes[] = 'height="' . (int) $height . '"';
     }
     if (is_object($GLOBALS['TSFE']) && $GLOBALS['TSFE']->config['config']['doctype'] !== 'html5') {
         $attributes[] = 'frameborder="0"';
     }
     foreach (['class', 'dir', 'id', 'lang', 'style', 'title', 'accesskey', 'tabindex', 'onclick', 'poster', 'preload'] as $key) {
         if (!empty($options[$key])) {
             $attributes[] = $key . '="' . htmlspecialchars($options[$key]) . '"';
         }
     }
     return sprintf('<iframe src="%s"%s></iframe>', $src, empty($attributes) ? '' : ' ' . implode(' ', $attributes));
 }
 /**
  * @param FileInterface $file
  * @param int|string $width TYPO3 known format; examples: 220, 200m or 200c
  * @param int|string $height TYPO3 known format; examples: 220, 200m or 200c
  * @param array $options
  * @param bool $usedPathsRelativeToCurrentScript See $file->getPublicUrl()
  * @return string
  */
 public function render(FileInterface $file, $width, $height, array $options = [], $usedPathsRelativeToCurrentScript = false)
 {
     $this->reset();
     $this->defaultWidth = $width;
     $this->defaultHeight = $height;
     if (is_callable([$file, 'getOriginalFile'])) {
         /** @var FileReference $file */
         $originalFile = $file->getOriginalFile();
     } else {
         $originalFile = $file;
     }
     try {
         $defaultProcessConfiguration = [];
         if ($this->getConfiguration()->getExtensionConfiguration()['enableSmallDefaultImage']) {
             $defaultProcessConfiguration['width'] = '360m';
         }
         $defaultProcessConfiguration['crop'] = $file->getProperty('crop');
     } catch (\InvalidArgumentException $e) {
         $defaultProcessConfiguration['crop'] = '';
     }
     $this->processSourceCollection($originalFile, $defaultProcessConfiguration);
     $src = $originalFile->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $defaultProcessConfiguration)->getPublicUrl();
     return $this->buildImageTag($src, $file, $options);
 }