src/Gzero/Cms/ViewModels/ContentViewModel.php
public function firstImageUrl($text, $default = null)
    {
        $url = $default;

        if (!empty($text)) {
            preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $text, $matches);
        }

        if (!empty($matches) && isset($matches[1])) {
            $url = $matches[1];
        }

        return $url;
    }
public function firstImageUrl($text, $default = null)
    {
        $url = $default;

        if (!empty($text)) {
            preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $text, $matches);
        }

        if (!empty($matches) && isset($matches[1])) {
            $url = $matches[1];
        }

        return $url;
    }
public function firstImageUrl ( $ text , $ default = null ) { $ url = $ default ; if ( ! empty ( $ text ) ) { preg_match ( '/< *img[^>]*src *= *["\']?([^"\']*)/i' , $ text , $ matches ) ; } if ( ! empty ( $ matches ) && isset ( $ matches [ 1 ] ) ) { $ url = $ matches [ 1 ] ; } return $ url ; }
This function returns the first img url from provided text

@param string $text    text to get first image url from

@param null   $default default url to return if image is not found

@return string first image url
This function returns the first img url from provided text