Esempio n. 1
0
 /**
  * @test
  */
 public function setOriginalImageAsPresetWithRandomValueAndCheckWidthAndHeightCorrespondsToThisRandomValue()
 {
     $preset = 'image_large';
     $actualWidth = rand(10, 100);
     $actualHeight = rand(10, 100);
     \Fab\Media\Utility\ConfigurationUtility::getInstance()->set('image_large', $actualWidth . 'x' . $actualHeight);
     $this->assertSame($actualWidth, $this->fixture->preset($preset)->getWidth());
     $this->assertSame($actualHeight, $this->fixture->preset($preset)->getHeight());
 }
Esempio n. 2
0
 /**
  * @return array
  */
 protected function getConfiguration()
 {
     $configuration = $this->thumbnailService->getConfiguration();
     if (empty($configuration)) {
         $dimension = ImagePresetUtility::getInstance()->preset('image_thumbnail');
         $configuration = array('width' => $dimension->getWidth(), 'height' => $dimension->getHeight());
     }
     return $configuration;
 }
Esempio n. 3
0
 /**
  * Returns preset values related to an image dimension
  *
  * @param string $preset
  * @param string $dimension
  * @return int
  */
 public function render($preset, $dimension = 'width')
 {
     $imageDimension = ImagePresetUtility::getInstance()->preset($preset);
     if ($dimension == 'width') {
         $result = $imageDimension->getWidth();
     } else {
         $result = $imageDimension->getHeight();
     }
     return $result;
 }
Esempio n. 4
0
 /**
  * Returns a configurable thumbnail of an asset
  *
  * @throws \Exception
  * @return string
  */
 public function render()
 {
     $file = $this->arguments['file'];
     $preset = $this->arguments['preset'];
     $configuration = $this->arguments['configuration'];
     $configurationWrap = $this->arguments['configurationWrap'];
     $attributes = $this->arguments['attributes'];
     $output = $this->arguments['output'];
     if ($file instanceof Content) {
         $file = $this->getFileConverter()->convert($file);
     }
     if ($preset) {
         $imageDimension = ImagePresetUtility::getInstance()->preset($preset);
         $configuration['width'] = $imageDimension->getWidth();
         $configuration['height'] = $imageDimension->getHeight();
     }
     /** @var $thumbnailService \Fab\Media\Thumbnail\ThumbnailService */
     $thumbnailService = GeneralUtility::makeInstance('Fab\\Media\\Thumbnail\\ThumbnailService', $file);
     $thumbnail = $thumbnailService->setConfiguration($configuration)->setConfigurationWrap($configurationWrap)->setAttributes($attributes)->setOutputType($output)->create();
     return $thumbnail;
 }