當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。