/** * Fetch a resource * * @param mixed $id * @return ApiProblem|mixed */ public function fetch($id) { $rendition = CoreInterface::RENDITION_ORIGINAL; if ($this->getEvent()) { $rendition = $this->getEvent()->getQueryParam('rendition', CoreInterface::RENDITION_ORIGINAL); } $src = $this->imageManager->getSrc($id, $rendition); if ($src && !$this->isAccept('application/json')) { return $this->getRedirectResponse($src); } $hasImage = $this->imageManager->has($id, $rendition); if ($hasImage) { $image = $this->imageManager->get($id, $rendition); if ($this->isAccept($image->getMimeType()) || $this->isAccept('*/*', true)) { return $this->getHttpResponse($image); } else { return $this->getApigilityResponse($image, $id); } } return new ApiProblem(404, 'Image not found'); }