‪TYPO3CMS  9.5
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  */
16 
21 
27 {
34  public function ‪render($conf = [])
35  {
36  $this->‪getTypoScriptFrontendController()->‪logDeprecatedTyposcript('cObject FILE', 'Use IMAGE to show images instead.');
37  $theValue = '';
38  $file = isset($conf['file.']) ? $this->cObj->stdWrap($conf['file'], $conf['file.']) : $conf['file'];
39  try {
40  $file = GeneralUtility::makeInstance(FilePathSanitizer::class)->sanitize($file);
41  if (file_exists($file)) {
42  $fileInfo = GeneralUtility::split_fileref($file);
43  $extension = $fileInfo['fileext'];
44  if ($extension === 'jpg' || $extension === 'jpeg' || $extension === 'gif' || $extension === 'png') {
45  $imageInfo = GeneralUtility::makeInstance(ImageInfo::class, $file);
46  $altParameters = trim($this->cObj->getAltParam($conf, false));
47  $theValue = '<img src="'
48  . htmlspecialchars($this->‪getTypoScriptFrontendController()->absRefPrefix . $file)
49  . '" width="' . (int)$imageInfo->getWidth() . '" height="' . (int)$imageInfo->getHeight()
50  . '"' . $this->cObj->getBorderAttr(' border="0"') . ' ' . $altParameters . ' />';
51  } elseif (filesize($file) < 1024 * 1024) {
52  $theValue = file_get_contents($file);
53  }
54  }
55  } catch (\‪TYPO3\CMS\Core\Resource\‪Exception $e) {
56  // do nothing
57  }
58  $linkWrap = isset($conf['linkWrap.']) ? $this->cObj->stdWrap($conf['linkWrap'], $conf['linkWrap.']) : $conf['linkWrap'];
59  if ($linkWrap) {
60  $theValue = $this->cObj->linkWrap($theValue, $linkWrap);
61  }
62  $wrap = isset($conf['wrap.']) ? $this->cObj->stdWrap($conf['wrap'], $conf['wrap.']) : $conf['wrap'];
63  if ($wrap) {
64  $theValue = $this->cObj->wrap($theValue, $wrap);
65  }
66  if (isset($conf['stdWrap.'])) {
67  $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
68  }
69  return $theValue;
70  }
71 
76  {
77  return ‪$GLOBALS['TSFE'];
78  }
79 }
‪TYPO3\CMS\Frontend\ContentObject\FileContentObject\getTypoScriptFrontendController
‪TypoScriptFrontendController getTypoScriptFrontendController()
Definition: FileContentObject.php:75
‪TYPO3
‪TYPO3\CMS\Frontend\ContentObject
Definition: AbstractContentObject.php:2
‪TYPO3\CMS\Frontend\ContentObject\FileContentObject\render
‪string render($conf=[])
Definition: FileContentObject.php:34
‪TYPO3\CMS\Frontend\Resource\FilePathSanitizer
Definition: FilePathSanitizer.php:37
‪TYPO3\CMS\Frontend\ContentObject\FileContentObject
Definition: FileContentObject.php:27
‪TYPO3\CMS\Frontend\ContentObject\AbstractContentObject
Definition: AbstractContentObject.php:24
‪TYPO3\CMS\Core\Type\File\ImageInfo
Definition: ImageInfo.php:25
‪TYPO3\CMS\Core\Resource\Exception
Definition: Exception.php:21
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController\logDeprecatedTyposcript
‪logDeprecatedTyposcript($typoScriptProperty, $explanation='')
Definition: TypoScriptFrontendController.php:4230
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
Definition: TypoScriptFrontendController.php:97
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45