TYPO3 CMS  TYPO3_8-7
FileContentObject.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
19 
24 {
31  public function render($conf = [])
32  {
33  $theValue = '';
34  $file = isset($conf['file.']) ? $this->cObj->stdWrap($conf['file'], $conf['file.']) : $conf['file'];
35  $file = $this->getTypoScriptFrontendController()->tmpl->getFileName($file);
36  if ($file !== null && file_exists($file)) {
37  $fileInfo = GeneralUtility::split_fileref($file);
38  $extension = $fileInfo['fileext'];
39  if ($extension === 'jpg' || $extension === 'jpeg' || $extension === 'gif' || $extension === 'png') {
40  $imageInfo = GeneralUtility::makeInstance(ImageInfo::class, $file);
41  $altParameters = trim($this->cObj->getAltParam($conf, false));
42  $theValue = '<img src="'
43  . htmlspecialchars($this->getTypoScriptFrontendController()->absRefPrefix . $file)
44  . '" width="' . (int)$imageInfo->getWidth() . '" height="' . (int)$imageInfo->getHeight()
45  . '"' . $this->cObj->getBorderAttr(' border="0"') . ' ' . $altParameters . ' />';
46  } elseif (filesize($file) < 1024 * 1024) {
47  $theValue = file_get_contents($file);
48  }
49  }
50 
51  $linkWrap = isset($conf['linkWrap.']) ? $this->cObj->stdWrap($conf['linkWrap'], $conf['linkWrap.']) : $conf['linkWrap'];
52  if ($linkWrap) {
53  $theValue = $this->cObj->linkWrap($theValue, $linkWrap);
54  }
55  $wrap = isset($conf['wrap.']) ? $this->cObj->stdWrap($conf['wrap'], $conf['wrap.']) : $conf['wrap'];
56  if ($wrap) {
57  $theValue = $this->cObj->wrap($theValue, $wrap);
58  }
59  if (isset($conf['stdWrap.'])) {
60  $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
61  }
62  return $theValue;
63  }
64 
68  protected function getTypoScriptFrontendController()
69  {
70  return $GLOBALS['TSFE'];
71  }
72 }
static makeInstance($className,... $constructorArguments)
static split_fileref($fileNameWithPath)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']