ImagePViewHelper.php 1.5 KB

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