opentalentImageService = $opentalentImageService; } /** * -- This method is expected by Fluid -- * Declares the viewhelper's parameters */ public function initializeArguments() { $this->registerArgument( 'fileId', 'int', 'The id of the File object', true ); $this->registerArgument( 'size', 'string', 'The expected size (sm, md, or lg)', false, 'md' ); $this->registerArgument( 'default', 'string', 'The src of the image if the file is not found', false, '' ); } /** * -- This method is expected by Fluid -- * Renders the content as html * * @return string Rendered tag */ public function render() { $fileId = $this->arguments['fileId']; $size = $this->arguments['size']; $default = $this->arguments['default']; try { return $this->opentalentImageService->getImageUrl($fileId, $size); } catch (ApiRequestException $e) { if ($e->getCode() === 404) { return $default; } } } }