<?php

namespace Opentalent\OtTemplating\ViewHelpers;

use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException;
use TYPO3\CMS\Fluid\ViewHelpers\ImageViewHelper;

/**
 * -- Wrapper for the TYPO3\CMS\Fluid\ViewHelpers\ImageViewHelper --
 * Display the image like the original viewhelper does, but does not
 * throw an error if the file is not an image or if the
 * image can not be displayed.
 *
 *     {namespace ot=Opentalent\OtTemplating\ViewHelpers}
 *
 *     {ot:imageP()}
 *
 * @package Opentalent\OtTemplating\ViewHelpers
 */
class ImagePViewHelper extends ImageViewHelper
{
    /**
     * -- This method is expected by Fluid --
     * Declares the viewhelper's parameters
     */
    public function initializeArguments()
    {
        parent::initializeArguments();
    }

    /**
     * -- This method is expected by Fluid --
     * Renders the content as html
     *
     * @return string Rendered tag
     */
    public function render() {
        try {
            return parent::render();
        } catch (ResourceDoesNotExistException |
                \UnexpectedValueException |
                \RuntimeException |
                \InvalidArgumentException
                $e) {
            return "";
        }
    }

}
