TYPO3 CMS  TYPO3_6-2
ImageDimensionViewHelper.php
Go to the documentation of this file.
1 <?php
3 
30 
38  public function render($dimension = 'width') {
39  if ($dimension !== 'width' && $dimension !== 'height') {
40  throw new \TYPO3\CMS\Install\ViewHelpers\Exception(
41  'Dimension must be either \'width\' or \'height\'',
42  1369563247
43  );
44  }
45  $absolutePathToFile = $this->renderChildren();
46  if (!is_file($absolutePathToFile)) {
47  throw new \TYPO3\CMS\Install\ViewHelpers\Exception(
48  'File not found',
49  1369563248
50  );
51  }
52  $actualDimension = getimagesize($absolutePathToFile);
53  if ($dimension === 'width') {
54  $size = $actualDimension[0];
55  } else {
56  $size = $actualDimension[1];
57  }
58  return $size;
59  }
60 }