当前位置: 首页>>代码示例>>PHP>>正文


PHP File::getOriginalFile方法代码示例

本文整理汇总了PHP中TYPO3\CMS\Core\Resource\File::getOriginalFile方法的典型用法代码示例。如果您正苦于以下问题:PHP File::getOriginalFile方法的具体用法?PHP File::getOriginalFile怎么用?PHP File::getOriginalFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\CMS\Core\Resource\File的用法示例。


在下文中一共展示了File::getOriginalFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getImgResource

 /**
  * Creates and returns a TypoScript "imgResource".
  * The value ($file) can either be a file reference (TypoScript resource) or the string "GIFBUILDER".
  * In the first case a current image is returned, possibly scaled down or otherwise processed.
  * In the latter case a GIFBUILDER image is returned; This means an image is made by TYPO3 from layers of elements as GIFBUILDER defines.
  * In the function IMG_RESOURCE() this function is called like $this->getImgResource($conf['file'], $conf['file.']);
  *
  * Structure of the returned info array:
  *  0 => width
  *  1 => height
  *  2 => file extension
  *  3 => file name
  *  origFile => original file name
  *  origFile_mtime => original file mtime
  *  -- only available if processed via FAL: --
  *  originalFile => original file object
  *  processedFile => processed file object
  *  fileCacheHash => checksum of processed file
  *
  * @param string|File|FileReference $file A "imgResource" TypoScript data type. Either a TypoScript file resource, a file or a file reference object or the string GIFBUILDER. See description above.
  * @param array $fileArray TypoScript properties for the imgResource type
  * @return array|NULL Returns info-array
  * @see IMG_RESOURCE(), cImage(), \TYPO3\CMS\Frontend\Imaging\GifBuilder
  */
 public function getImgResource($file, $fileArray)
 {
     if (empty($file) && empty($fileArray)) {
         return null;
     }
     if (!is_array($fileArray)) {
         $fileArray = (array) $fileArray;
     }
     $imageResource = null;
     $tsfe = $this->getTypoScriptFrontendController();
     if ($file === 'GIFBUILDER') {
         /** @var GifBuilder $gifCreator */
         $gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
         $gifCreator->init();
         $theImage = '';
         if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']) {
             $gifCreator->start($fileArray, $this->data);
             $theImage = $gifCreator->gifBuild();
         }
         $imageResource = $gifCreator->getImageDimensions($theImage);
         $imageResource['origFile'] = $theImage;
     } else {
         if ($file instanceof File) {
             $fileObject = $file;
         } elseif ($file instanceof FileReference) {
             $fileObject = $file->getOriginalFile();
             if (!isset($fileArray['crop'])) {
                 $fileArray['crop'] = $file->getProperty('crop');
             }
         } else {
             try {
                 if ($fileArray['import.']) {
                     $importedFile = trim($this->stdWrap('', $fileArray['import.']));
                     if (!empty($importedFile)) {
                         $file = $importedFile;
                     }
                 }
                 if (MathUtility::canBeInterpretedAsInteger($file)) {
                     $treatIdAsReference = isset($fileArray['treatIdAsReference.']) ? $this->stdWrap($fileArray['treatIdAsReference'], $fileArray['treatIdAsReference.']) : $fileArray['treatIdAsReference'];
                     if (!empty($treatIdAsReference)) {
                         $fileReference = $this->getResourceFactory()->getFileReferenceObject($file);
                         $fileObject = $fileReference->getOriginalFile();
                         if (!isset($fileArray['crop'])) {
                             $fileArray['crop'] = $fileReference->getProperty('crop');
                         }
                     } else {
                         $fileObject = $this->getResourceFactory()->getFileObject($file);
                     }
                 } elseif (preg_match('/^(0|[1-9][0-9]*):/', $file)) {
                     // combined identifier
                     $fileObject = $this->getResourceFactory()->retrieveFileOrFolderObject($file);
                 } else {
                     if (isset($importedFile) && !empty($importedFile) && !empty($fileArray['import'])) {
                         $file = $fileArray['import'] . $file;
                     }
                     $fileObject = $this->getResourceFactory()->retrieveFileOrFolderObject($file);
                 }
             } catch (Exception $exception) {
                 /** @var \TYPO3\CMS\Core\Log\Logger $logger */
                 $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
                 $logger->warning('The image "' . $file . '" could not be found and won\'t be included in frontend output');
                 return null;
             }
         }
         if ($fileObject instanceof File) {
             $processingConfiguration = array();
             $processingConfiguration['width'] = isset($fileArray['width.']) ? $this->stdWrap($fileArray['width'], $fileArray['width.']) : $fileArray['width'];
             $processingConfiguration['height'] = isset($fileArray['height.']) ? $this->stdWrap($fileArray['height'], $fileArray['height.']) : $fileArray['height'];
             $processingConfiguration['fileExtension'] = isset($fileArray['ext.']) ? $this->stdWrap($fileArray['ext'], $fileArray['ext.']) : $fileArray['ext'];
             $processingConfiguration['maxWidth'] = isset($fileArray['maxW.']) ? (int) $this->stdWrap($fileArray['maxW'], $fileArray['maxW.']) : (int) $fileArray['maxW'];
             $processingConfiguration['maxHeight'] = isset($fileArray['maxH.']) ? (int) $this->stdWrap($fileArray['maxH'], $fileArray['maxH.']) : (int) $fileArray['maxH'];
             $processingConfiguration['minWidth'] = isset($fileArray['minW.']) ? (int) $this->stdWrap($fileArray['minW'], $fileArray['minW.']) : (int) $fileArray['minW'];
             $processingConfiguration['minHeight'] = isset($fileArray['minH.']) ? (int) $this->stdWrap($fileArray['minH'], $fileArray['minH.']) : (int) $fileArray['minH'];
             $processingConfiguration['noScale'] = isset($fileArray['noScale.']) ? $this->stdWrap($fileArray['noScale'], $fileArray['noScale.']) : $fileArray['noScale'];
             $processingConfiguration['additionalParameters'] = isset($fileArray['params.']) ? $this->stdWrap($fileArray['params'], $fileArray['params.']) : $fileArray['params'];
             $processingConfiguration['frame'] = isset($fileArray['frame.']) ? (int) $this->stdWrap($fileArray['frame'], $fileArray['frame.']) : (int) $fileArray['frame'];
//.........这里部分代码省略.........
开发者ID:vip3out,项目名称:TYPO3.CMS,代码行数:101,代码来源:ContentObjectRenderer.php


注:本文中的TYPO3\CMS\Core\Resource\File::getOriginalFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。