ImagePViewHelper.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Opentalent\OtTemplating\ViewHelpers;
  3. use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException;
  4. use TYPO3\CMS\Fluid\ViewHelpers\ImageViewHelper;
  5. /**
  6. * -- Wrapper for the TYPO3\CMS\Fluid\ViewHelpers\ImageViewHelper --
  7. * Display the image like the original viewhelper does, but does not
  8. * throw an error if the file is not an image or if the
  9. * image can not be displayed.
  10. *
  11. * {namespace ot=Opentalent\OtTemplating\ViewHelpers}
  12. *
  13. * {ot:imageP()}
  14. *
  15. * @package Opentalent\OtTemplating\ViewHelpers
  16. */
  17. class ImagePViewHelper extends ImageViewHelper
  18. {
  19. /**
  20. * -- This method is expected by Fluid --
  21. * Declares the viewhelper's parameters
  22. */
  23. public function initializeArguments()
  24. {
  25. parent::initializeArguments();
  26. }
  27. /**
  28. * -- This method is expected by Fluid --
  29. * Renders the content as html
  30. *
  31. * @return string Rendered tag
  32. */
  33. public function render() {
  34. try {
  35. return parent::render();
  36. } catch (ResourceDoesNotExistException |
  37. \UnexpectedValueException |
  38. \RuntimeException |
  39. \InvalidArgumentException
  40. $e) {
  41. return "";
  42. }
  43. }
  44. }