Example #1
0
 /**
  * Get post first image path
  *
  * @param Post   $post   Current post
  * @param string $filter Image filter
  * @param string $host   Current host
  *
  * @return string
  */
 public function getPostFirstImagePath(Post $post, $filter = '', $host = '')
 {
     $imagePath = '';
     if (preg_match('~<img[^>]+src="([^"]+)"[^>]*>~i', $post->getText(), $matches)) {
         $imagePath = $this->cachePathResolver->getBrowserPath($matches[1], $filter);
     }
     if ('' === $filter && isset($matches[1])) {
         $imagePath = $matches[1];
     }
     return $imagePath;
 }