/** * Get rendition preview * * @param Newscoop\Image\Rendition $rendition * @param int $width * @param int $height * @param Newscoop\Image\ArticleRendition $articleImageRendition * @return string */ public function rendition(Rendition $rendition, $width, $height, ArticleRendition $articleRendition = null) { if ($articleRendition !== null) { $preview = $articleRendition->getRendition()->getPreview($width, $height); $preview->setCoords($articleRendition->getImageSpecs()); $thumbnail = $rendition->fits($articleRendition->getImage()) ? $this->imageService->getThumbnail($preview, $articleRendition->getImage()) : null; } else { $preview = $rendition->getPreview($width, $height); $thumbnail = null; } $this->view->isDefault = $thumbnail === null || $articleRendition->isDefault(); $this->view->preview = $preview; $this->view->rendition = $rendition; $this->view->thumbnail = $thumbnail; return $this->view->render('image/rendition.phtml'); }
/** * Get preview * * @param int $renditionWidth * @param int $renditionHeight * @param int $previewWidth * @param int $previewHeight * @return Newscoop\Image\RenditionPreview */ private function getPreview($renditionWidth, $renditionHeight, $previewWidth, $previewHeight) { $rendition = new Rendition($renditionWidth, $renditionHeight); return $rendition->getPreview($previewWidth, $previewHeight); }