Example #1
0
 /**
  * @param Item $item
  * @param Crawler $body
  * @param string $id
  *
  * @return Item
  */
 public function setCover(Item $item, Crawler $body, $id)
 {
     if ($image = $body->filter('picture')->text()) {
         try {
             $image = $this->browser->getImageUrl($image);
             if ($path = parse_url($image, PHP_URL_PATH)) {
                 $ext = pathinfo($path, PATHINFO_EXTENSION);
                 $item->setCover(self::NAME . '/' . $id . '/cover.' . $ext);
                 $this->uploadImageFromUrl($image, $item);
             }
         } catch (\Exception $e) {
             // error while retrieving images is not critical
         }
     }
     return $item;
 }
 /**
  * Test get image url
  */
 public function testGetImageUrl()
 {
     $this->assertEquals($this->image_prefix . 'foo', $this->browser->getImageUrl('foo'));
 }