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


PHP ContentObjectRenderer::getImgResource方法代码示例

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


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

示例1: preprocessImages

 /**
  * @param array $files
  * @param boolean $onlyProperties
  * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
  * @return array|NULL
  */
 public function preprocessImages($files, $onlyProperties = FALSE)
 {
     if (TRUE === empty($files)) {
         return NULL;
     }
     if ('BE' === TYPO3_MODE) {
         $this->simulateFrontendEnvironment();
     }
     $setup = array('width' => $this->arguments['width'], 'height' => $this->arguments['height'], 'minW' => $this->arguments['minWidth'], 'minH' => $this->arguments['minHeight'], 'maxW' => $this->arguments['maxWidth'], 'maxH' => $this->arguments['maxHeight'], 'treatIdAsReference' => FALSE);
     $images = array();
     foreach ($files as $file) {
         $imageInfo = $this->contentObject->getImgResource($file->getUid(), $setup);
         $GLOBALS['TSFE']->lastImageInfo = $imageInfo;
         if (FALSE === is_array($imageInfo)) {
             throw new Exception('Could not get image resource for "' . htmlspecialchars($file->getCombinedIdentifier()) . '".', 1253191060);
         }
         if ((double) substr(TYPO3_version, 0, 3) < 7.1) {
             $imageInfo[3] = GeneralUtility::png_to_gif_by_imagemagick($imageInfo[3]);
         } else {
             $imageInfo[3] = GraphicalFunctions::pngToGifByImagemagick($imageInfo[3]);
         }
         $imageInfo[3] = GeneralUtility::png_to_gif_by_imagemagick($imageInfo[3]);
         $GLOBALS['TSFE']->imagesOnPage[] = $imageInfo[3];
         $imageSource = $GLOBALS['TSFE']->absRefPrefix . GeneralUtility::rawUrlEncodeFP($imageInfo[3]);
         if (TRUE === $onlyProperties) {
             $file = ResourceUtility::getFileArray($file);
         }
         $images[] = array('info' => $imageInfo, 'source' => $imageSource, 'file' => $file);
     }
     if ('BE' === TYPO3_MODE) {
         $this->resetFrontendEnvironment();
     }
     return $images;
 }
开发者ID:JostBaron,项目名称:vhs,代码行数:40,代码来源:AbstractImageViewHelper.php

示例2: render

 /**
  * Render method
  *
  * @return string
  */
 public function render()
 {
     $src = $this->viewHelperVariableContainer->get(self::SCOPE, self::SCOPE_VARIABLE_SRC);
     if ('BE' === TYPO3_MODE) {
         $tsfeBackup = FrontendSimulationUtility::simulateFrontendEnvironment();
     }
     $setup = array('width' => $this->arguments['width'], 'height' => $this->arguments['height'], 'minW' => $this->arguments['minW'], 'minH' => $this->arguments['minH'], 'maxW' => $this->arguments['maxW'], 'maxH' => $this->arguments['maxH']);
     $quality = $this->arguments['quality'];
     $format = $this->arguments['format'];
     if (FALSE === empty($format)) {
         $setup['ext'] = $format;
     }
     if (0 < intval($quality)) {
         $quality = MathUtility::forceIntegerInRange($quality, 10, 100, 75);
         $setup['params'] .= ' -quality ' . $quality;
     }
     if ('BE' === TYPO3_MODE && '../' === substr($src, 0, 3)) {
         $src = substr($src, 3);
     }
     $result = $this->contentObject->getImgResource($src, $setup);
     if ('BE' === TYPO3_MODE) {
         FrontendSimulationUtility::resetFrontendEnvironment($tsfeBackup);
     }
     $src = $this->preprocessSourceUri(rawurldecode($result[3]));
     if (NULL === $this->arguments['media']) {
         $this->viewHelperVariableContainer->addOrUpdate(self::SCOPE, self::SCOPE_VARIABLE_DEFAULT_SOURCE, $src);
     } else {
         $this->tag->addAttribute('media', $this->arguments['media']);
     }
     $this->tag->addAttribute('srcset', $src);
     return $this->tag->render();
 }
开发者ID:smichaelsen,项目名称:vhs,代码行数:37,代码来源:SourceViewHelper.php

示例3: render

 /**
  * Resizes a given image (if required) and renders the respective img tag
  * @see http://typo3.org/documentation/document-library/references/doc_core_tsref/4.2.0/view/1/5/#id4164427
  *
  * @param string $src
  * @param string $width width of the image. This can be a numeric value representing the fixed width of the image in pixels. But you can also perform simple calculations by adding "m" or "c" to the value. See imgResource.width for possible options.
  * @param string $height height of the image. This can be a numeric value representing the fixed height of the image in pixels. But you can also perform simple calculations by adding "m" or "c" to the value. See imgResource.width for possible options.
  * @param integer $minWidth minimum width of the image
  * @param integer $minHeight minimum height of the image
  * @param integer $maxWidth maximum width of the image
  * @param integer $maxHeight maximum height of the image
  *
  * @return string rendered tag.
  * @author Sebastian Böttger <sboettger@cross-content.com>
  * @author Bastian Waidelich <bastian@typo3.org>
  */
 public function render($src, $width = NULL, $height = NULL, $minWidth = NULL, $minHeight = NULL, $maxWidth = NULL, $maxHeight = NULL)
 {
     if (TYPO3_MODE === 'BE') {
         $this->simulateFrontendEnvironment();
     }
     $setup = array('width' => $width, 'height' => $height, 'minW' => $minWidth, 'minH' => $minHeight, 'maxW' => $maxWidth, 'maxH' => $maxHeight);
     $src = current(\TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(chr(10), $src));
     // Just get the first one, in case this came from a field of
     if (TYPO3_MODE === 'BE' && substr($src, 0, 3) === '../') {
         $src = substr($src, 3);
     }
     $imageInfo = $this->contentObject->getImgResource($src, $setup);
     $GLOBALS['TSFE']->lastImgResourceInfo = $imageInfo;
     if (!is_array($imageInfo)) {
         throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception('Could not get image resource for "' . htmlspecialchars($src) . '".', 1253191060);
     }
     $imageInfo[3] = \TYPO3\CMS\Core\Utility\GeneralUtility::png_to_gif_by_imagemagick($imageInfo[3]);
     $GLOBALS['TSFE']->imagesOnPage[] = $imageInfo[3];
     $imageSource = $GLOBALS['TSFE']->absRefPrefix . \TYPO3\CMS\Core\Utility\GeneralUtility::rawUrlEncodeFP($imageInfo[3]);
     if (TYPO3_MODE === 'BE') {
         $imageSource = '../' . $imageSource;
         $this->resetFrontendEnvironment();
     }
     return $imageSource;
 }
开发者ID:electricretina,项目名称:cicbase,代码行数:41,代码来源:ImageResourceViewHelper.php

示例4: getImgResourceCallsGetImgResourcePostProcessHook

 /**
  * @test
  */
 public function getImgResourceCallsGetImgResourcePostProcessHook()
 {
     $this->templateServiceMock->expects($this->atLeastOnce())->method('getFileName')->with('typo3/clear.gif')->will($this->returnValue('typo3/clear.gif'));
     $resourceFactory = $this->getMock(\TYPO3\CMS\Core\Resource\ResourceFactory::class, array(), array(), '', false);
     $this->subject->expects($this->any())->method('getResourceFactory')->will($this->returnValue($resourceFactory));
     $className = $this->getUniqueId('tx_coretest');
     $getImgResourceHookMock = $this->getMock(\TYPO3\CMS\Frontend\ContentObject\ContentObjectGetImageResourceHookInterface::class, array('getImgResourcePostProcess'), array(), $className);
     $getImgResourceHookMock->expects($this->once())->method('getImgResourcePostProcess')->will($this->returnCallback(array($this, 'isGetImgResourceHookCalledCallback')));
     $getImgResourceHookObjects = array($getImgResourceHookMock);
     $this->subject->_setRef('getImgResourceHookObjects', $getImgResourceHookObjects);
     $this->subject->getImgResource('typo3/clear.gif', array());
 }
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:15,代码来源:ContentObjectRendererTest.php

示例5: preprocessImage

 /**
  * @throws Exception
  * @return void
  */
 public function preprocessImage()
 {
     $src = $this->arguments['src'];
     $width = $this->arguments['width'];
     $height = $this->arguments['height'];
     $minW = $this->arguments['minW'];
     $minH = $this->arguments['minH'];
     $maxW = $this->arguments['maxW'];
     $maxH = $this->arguments['maxH'];
     $format = $this->arguments['format'];
     $quality = $this->arguments['quality'];
     $treatIdAsReference = (bool) $this->arguments['treatIdAsReference'];
     if ('BE' === TYPO3_MODE) {
         $this->simulateFrontendEnvironment();
     }
     $setup = array('width' => $width, 'height' => $height, 'minW' => $minW, 'minH' => $minH, 'maxW' => $maxW, 'maxH' => $maxH, 'treatIdAsReference' => $treatIdAsReference);
     if (FALSE === empty($format)) {
         $setup['ext'] = $format;
     }
     if (0 < intval($quality)) {
         $quality = MathUtility::forceIntegerInRange($quality, 10, 100, 75);
         $setup['params'] = '-quality ' . $quality;
     }
     if ('BE' === TYPO3_MODE && '../' === substr($src, 0, 3)) {
         $src = substr($src, 3);
     }
     $this->imageInfo = $this->contentObject->getImgResource($src, $setup);
     $GLOBALS['TSFE']->lastImageInfo = $this->imageInfo;
     if (FALSE === is_array($this->imageInfo)) {
         throw new Exception('Could not get image resource for "' . htmlspecialchars($src) . '".', 1253191060);
     }
     if ((double) substr(TYPO3_version, 0, 3) < 7.1) {
         $this->imageInfo[3] = GeneralUtility::png_to_gif_by_imagemagick($this->imageInfo[3]);
     } else {
         $this->imageInfo[3] = GraphicalFunctions::pngToGifByImagemagick($this->imageInfo[3]);
     }
     $GLOBALS['TSFE']->imagesOnPage[] = $this->imageInfo[3];
     $publicUrl = rawurldecode($this->imageInfo[3]);
     $this->mediaSource = $GLOBALS['TSFE']->absRefPrefix . GeneralUtility::rawUrlEncodeFP($publicUrl);
     if ('BE' === TYPO3_MODE) {
         $this->resetFrontendEnvironment();
     }
 }
开发者ID:JostBaron,项目名称:vhs,代码行数:47,代码来源:AbstractImageViewHelper.php

示例6: preprocessImage

 /**
  * @param string|null $imageSource
  * @throws Exception
  */
 public function preprocessImage($imageSource = null)
 {
     $src = null === $imageSource ? $this->arguments['src'] : $imageSource;
     $width = $this->arguments['width'];
     $height = $this->arguments['height'];
     $minW = $this->arguments['minW'];
     $minH = $this->arguments['minH'];
     $maxW = $this->arguments['maxW'];
     $maxH = $this->arguments['maxH'];
     $format = $this->arguments['format'];
     $quality = $this->arguments['quality'];
     $treatIdAsReference = (bool) $this->arguments['treatIdAsReference'];
     $crop = $this->arguments['crop'];
     if (is_object($src) && $src instanceof FileReference) {
         $src = $src->getUid();
         $treatIdAsReference = true;
     }
     if ($crop === null) {
         $crop = is_object($src) && $src instanceof FileReference ? $src->getProperty('crop') : null;
     }
     if ('BE' === TYPO3_MODE) {
         $this->simulateFrontendEnvironment();
     }
     $setup = ['width' => $width, 'height' => $height, 'minW' => $minW, 'minH' => $minH, 'maxW' => $maxW, 'maxH' => $maxH, 'treatIdAsReference' => $treatIdAsReference, 'crop' => $crop];
     if (false === empty($format)) {
         $setup['ext'] = $format;
     }
     if (0 < (int) $quality) {
         $quality = MathUtility::forceIntegerInRange($quality, 10, 100, 75);
         $setup['params'] = '-quality ' . $quality;
     }
     if (TYPO3_MODE === 'BE' && strpos($src, '../') === 0) {
         $src = substr($src, 3);
     }
     $this->imageInfo = $this->contentObject->getImgResource($src, $setup);
     $GLOBALS['TSFE']->lastImageInfo = $this->imageInfo;
     if (false === is_array($this->imageInfo)) {
         throw new Exception('Could not get image resource for "' . htmlspecialchars($src) . '".', 1253191060);
     }
     if ($this->hasArgument('canvasWidth') && $this->hasArgument('canvasHeight')) {
         $canvasWidth = (int) $this->arguments['canvasWidth'];
         $canvasHeight = (int) $this->arguments['canvasHeight'];
         $canvasColor = str_replace('#', '', $this->arguments['canvasColor']);
         $originalFilename = $this->imageInfo[3];
         $originalExtension = substr($originalFilename, -3);
         $destinationFilename = 'typo3temp/vhs-canvas-' . md5($originalFilename . $canvasColor . $canvasWidth . $canvasHeight) . '.' . $originalExtension;
         $destinationFilepath = GeneralUtility::getFileAbsFileName($destinationFilename);
         if (!file_exists($destinationFilepath)) {
             $arguments = sprintf('%s -background \'#%s\' -gravity center -extent %dx%d %s', $originalFilename, $canvasColor, $canvasWidth, $canvasHeight, $destinationFilepath);
             $command = CommandUtility::imageMagickCommand('convert', $arguments);
             CommandUtility::exec($command);
         }
         $this->imageInfo[3] = $destinationFilename;
     }
     $GLOBALS['TSFE']->imagesOnPage[] = $this->imageInfo[3];
     $GLOBALS['TSFE']->imagesOnPage[] = $this->imageInfo[3];
     $publicUrl = rawurldecode($this->imageInfo[3]);
     $this->mediaSource = GeneralUtility::rawUrlEncodeFP($publicUrl);
     if (TYPO3_MODE === 'BE') {
         $this->resetFrontendEnvironment();
     }
 }
开发者ID:fluidtypo3,项目名称:vhs,代码行数:66,代码来源:AbstractImageViewHelper.php


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