/**
* Extract image from text as thumbnail
*
* @param  string
* @return string
*/
function TEXT2THUMB($text, $w = 320, $h = 200, $class = '', $key = 0)
{
    $tmp_text = trim($text);
    $tmp_text = Marker::decode($tmp_text);
    preg_match_all('/src="([^"]*)"/i', $tmp_text, $matches);
    if (!empty($matches[1])) {
        $file = PATH2FILE($matches[1][$key]);
        $thumbs = Config::get('cms::theme.thumb');
        foreach ($thumbs as $val) {
            $file = str_replace($val['suffix'], '', $file);
        }
        return Marker::THUMB(array('file' => $file, 'w' => $w, 'class' => $class));
    } else {
        $thumbs = Config::get('cms::theme.thumb');
        $url = URL::to_action('cms::image@thumb', array($w, $h, 'no', 'img_default.jpg'));
        return HTML::image($url, '', array('width' => $w, 'height' => $h, 'class' => $class));
    }
}