/** * Get min size * * @param Newscoop\Image\ImageInterface $image * @return array */ public function getMinSize(ImageInterface $image) { list($width, $height) = \Newscoop\Image\ImageService::calculateSize($image->getWidth(), $image->getHeight(), $this->width, $this->height, $this->getFlags()); $ratio = max($width / (double) $image->getWidth(), $height / (double) $image->getHeight()); return array($this->width, $this->height); }
/** * Get thumbnail * * @param Newscoop\Image\ImageInterface $image * @param Newscoop\Image\ImageService $imageService * @return Newscoop\Image\Thumbnail */ public function getThumbnail(ImageInterface $image, ImageService $imageService) { if (!$this->fits($image)) { throw new \InvalidArgumentException("Image is too small."); } list($width, $height) = NetteImage::calculateSize($image->getWidth(), $image->getHeight(), $this->width, $this->height, $this->getFlags()); if ($this->isCrop()) { $width = min($width, $this->width); $height = min($height, $this->height); } return new Thumbnail($imageService->getSrc($image->getPath(), $this->width, $this->height, $this->getSpecs()), $width, $height); }
/** * Get document representation for user * * @param Newscoop\Entity\User $user * @return array */ public function getDocument(DocumentInterface $user) { return array('id' => $this->getDocumentId($user), 'number' => $user->getId(), 'type' => 'user', 'user' => $user->getUsername(), 'bio' => $user->getAttribute('bio'), 'image' => $this->imageService->getUserImage($user) ?: '', 'published' => gmdate(self::DATE_FORMAT, $user->getCreated()->getTimestamp()), 'is_verified' => (bool) $user->getAttribute(UserAttribute::IS_VERIFIED)); }