Beispiel #1
0
 /**
  * Publish picture item
  *
  * @param Newscoop\News\NewsItem $item
  * @return Image
  */
 private function publishPicture(NewsItem $item)
 {
     $rendition = $item->getContentSet()->getRemoteContent('rend:baseImage') ?: $item->getContentSet()->getRemoteContent('rend:viewImage');
     $realpath = tempnam('/tmp', 'picture');
     file_put_contents($realpath, file_get_contents($item->getFeed()->getRemoteContentSrc($rendition)));
     $imagesize = getimagesize($realpath);
     $info = array('name' => uniqid(), 'type' => $imagesize['mime'], 'tmp_name' => $realpath, 'size' => filesize($realpath), 'error' => 0);
     $attributes = array('Photographer' => $item->getContentMeta()->getByline(), 'Description' => $item->getContentMeta()->getHeadline(), 'Source' => \Newscoop\Entity\Picture::SOURCE_INGEST, 'Caption' => $item->getContentMeta()->getDescription(), 'Status' => \Newscoop\Entity\Picture::STATUS_APPROVED, 'Date' => $item->getItemMeta()->getFirstCreated()->format(self::DATE_FORMAT), 'Place' => $item->getContentMeta()->getSubject('cptType:5')->getName());
     return \Image::OnImageUpload($info, $attributes, null, null, true);
 }