protected function extractImages($html)
    {
        if (empty($html)) {
            return [];
        }

        $libxmlPreviousState = libxml_use_internal_errors(true);

        $dom = new DOMDocument;
        $dom->loadHTML($html);

        libxml_clear_errors();
        libxml_use_internal_errors($libxmlPreviousState);

        $images = [];

        //Gets all image tags
        foreach ($dom->getElementsByTagName('img') as $item) {
            $src = $item->getAttribute('src');

            if (in_array(strtolower(pathinfo($src, PATHINFO_EXTENSION)), ['gif', 'jpg', 'jpeg', 'png'])) {
                $images[] = $src;
            }
        }

        //Gets all Youtube videos
        if (preg_match_all('/\[youtube](.+?)\[\/youtube]/', $html, $items)) {
            foreach ($items[1] as $item) {
                $images[] = Youtube::getPreview($item);
            }
        }

        return $images;
    }
protected function extractImages($html)
    {
        if (empty($html)) {
            return [];
        }

        $libxmlPreviousState = libxml_use_internal_errors(true);

        $dom = new DOMDocument;
        $dom->loadHTML($html);

        libxml_clear_errors();
        libxml_use_internal_errors($libxmlPreviousState);

        $images = [];

        //Gets all image tags
        foreach ($dom->getElementsByTagName('img') as $item) {
            $src = $item->getAttribute('src');

            if (in_array(strtolower(pathinfo($src, PATHINFO_EXTENSION)), ['gif', 'jpg', 'jpeg', 'png'])) {
                $images[] = $src;
            }
        }

        //Gets all Youtube videos
        if (preg_match_all('/\[youtube](.+?)\[\/youtube]/', $html, $items)) {
            foreach ($items[1] as $item) {
                $images[] = Youtube::getPreview($item);
            }
        }

        return $images;
    }
protected function extractImages ( $ html ) { if ( empty ( $ html ) ) { return [ ] ; } $ libxmlPreviousState = libxml_use_internal_errors ( true ) ; $ dom = new DOMDocument ; $ dom -> loadHTML ( $ html ) ; libxml_clear_errors ( ) ; libxml_use_internal_errors ( $ libxmlPreviousState ) ; $ images = [ ] ; //Gets all image tags foreach ( $ dom -> getElementsByTagName ( 'img' ) as $ item ) { $ src = $ item -> getAttribute ( 'src' ) ; if ( in_array ( strtolower ( pathinfo ( $ src , PATHINFO_EXTENSION ) ) , [ 'gif' , 'jpg' , 'jpeg' , 'png' ] ) ) { $ images [ ] = $ src ; } } //Gets all Youtube videos if ( preg_match_all ( '/\[youtube](.+?)\[\/youtube]/' , $ html , $ items ) ) { foreach ( $ items [ 1 ] as $ item ) { $ images [ ] = Youtube :: getPreview ( $ item ) ; } } return $ images ; }
Internal method to extract all images from an html string, including the
previews of Youtube videos
@param string $html Html string
@return array
@since 2.23.0
Internal method to extract all images from an html string including the previews of Youtube videos