public function getPostImg($post, $options = array())
{
$this->setContent($post['BlogPost']['blog_content_id']);
$options = array_merge($_options = array('num' => 1, 'link' => true, 'alt' => $post['BlogPost']['name']), $options);
extract($options);
unset($options['num']);
unset($options['link']);
$contents = $post['BlogPost']['content'] . $post['BlogPost']['detail'];
$pattern = '/<img.*?src="([^"]+)"[^>]*>/is';
if (!preg_match_all($pattern, $contents, $matches)) {
return '';
}
if (isset($matches[1][$num - 1])) {
$url = $matches[1][$num - 1];
$url = preg_replace('/^' . preg_quote($this->base, '/') . '/', '', $url);
$img = $this->BcBaser->getImg($url, $options);
if ($link) {
return $this->BcBaser->getLink($img, $this->request->params['Content']['url'] . 'archives/' . $post['BlogPost']['no']);
} else {
return $img;
}
} else {
return '';
}
}