TYPO3 CMS  TYPO3_6-2
MagicImageService.php
Go to the documentation of this file.
1 <?php
3 
18 
25 
32  protected $magicImageMaximumWidth = 300;
33 
38  protected $magicImageMaximumHeight = 1000;
39 
47  public function createMagicImage(Resource\File $imageFileObject, array $fileConfiguration) {
48  // Process dimensions
49  $maxWidth = MathUtility::forceIntegerInRange($fileConfiguration['width'], 0, $this->magicImageMaximumWidth);
50  $maxHeight = MathUtility::forceIntegerInRange($fileConfiguration['height'], 0, $this->magicImageMaximumHeight);
51  if (!$maxWidth) {
53  }
54  if (!$maxHeight) {
55  $maxHeight = $this->magicImageMaximumHeight;
56  }
57  // Create the magic image
58  $magicImage = $imageFileObject->process(
60  array(
61  'width' => $maxWidth . 'm',
62  'height' => $maxHeight . 'm'
63  )
64  );
65  return $magicImage;
66  }
67 
74  public function setMagicImageMaximumDimensions(array $rteConfiguration) {
75  // Get maximum dimensions from the configuration of the RTE image button
76  $imageButtonConfiguration = (is_array($rteConfiguration['buttons.']) && is_array($rteConfiguration['buttons.']['image.'])) ? $rteConfiguration['buttons.']['image.'] : array();
77  if (is_array($imageButtonConfiguration['options.']) && is_array($imageButtonConfiguration['options.']['magic.'])) {
78  if ((int) $imageButtonConfiguration['options.']['magic.']['maxWidth'] > 0) {
79  $this->magicImageMaximumWidth = (int) $imageButtonConfiguration['options.']['magic.']['maxWidth'];
80  }
81  if ((int) $imageButtonConfiguration['options.']['magic.']['maxHeight'] > 0) {
82  $this->magicImageMaximumHeight = (int) $imageButtonConfiguration['options.']['magic.']['maxHeight'];
83  }
84  }
85  }
86 }
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
Definition: MathUtility.php:32
createMagicImage(Resource\File $imageFileObject, array $fileConfiguration)