private function loadStyleSheetAsset($css){

        $imageRe = "/url\\s*\\(['|\"]?([^)]*\.(png|jpg|jpeg|gif|svg))['|\"]?\\)/mi";
        $importRe = "/@import\\s*(url\\s*\\()?['\"]?([^;]*)['\"]/mi";
        $fontFaceRe = "/@font-face\\s*\\{(.*)?\\}/mi";
        $fontRe = "/url\\s*\\(['|\"]?([^)'|\"]*)['|\"]?\\)/i";

        //extract images
        preg_match_all($imageRe, $css, $matches);
        if(isset($matches[1])){
            foreach($matches[1] as $match){
                $this->addAsset('img', $match);
            }
        }

        //extract @import
        preg_match_all($importRe, $css, $matches);
        if(isset($matches[2])){
            foreach($matches[2] as $match){
                $this->addAsset('css', $match);
            }
        }

        //extract fonts
        preg_match_all($fontFaceRe, $css, $matches);
        if(isset($matches[1])){
            foreach($matches[1] as $faceMatch){
                preg_match_all($fontRe, $faceMatch, $fontMatches);
                if(isset($fontMatches[1])){
                    foreach($fontMatches[1] as $fontMatch){
                        $this->addAsset('font', $fontMatch);
                    }
                }
            }
        }
    }
private function loadStyleSheetAsset($css){

        $imageRe = "/url\\s*\\(['|\"]?([^)]*\.(png|jpg|jpeg|gif|svg))['|\"]?\\)/mi";
        $importRe = "/@import\\s*(url\\s*\\()?['\"]?([^;]*)['\"]/mi";
        $fontFaceRe = "/@font-face\\s*\\{(.*)?\\}/mi";
        $fontRe = "/url\\s*\\(['|\"]?([^)'|\"]*)['|\"]?\\)/i";

        //extract images
        preg_match_all($imageRe, $css, $matches);
        if(isset($matches[1])){
            foreach($matches[1] as $match){
                $this->addAsset('img', $match);
            }
        }

        //extract @import
        preg_match_all($importRe, $css, $matches);
        if(isset($matches[2])){
            foreach($matches[2] as $match){
                $this->addAsset('css', $match);
            }
        }

        //extract fonts
        preg_match_all($fontFaceRe, $css, $matches);
        if(isset($matches[1])){
            foreach($matches[1] as $faceMatch){
                preg_match_all($fontRe, $faceMatch, $fontMatches);
                if(isset($fontMatches[1])){
                    foreach($fontMatches[1] as $fontMatch){
                        $this->addAsset('font', $fontMatch);
                    }
                }
            }
        }
    }
private function loadStyleSheetAsset ( $ css ) { $ imageRe = "/url\\s*\\(['|\"]?([^)]*\.(png|jpg|jpeg|gif|svg))['|\"]?\\)/mi" ; $ importRe = "/@import\\s*(url\\s*\\()?['\"]?([^;]*)['\"]/mi" ; $ fontFaceRe = "/@font-face\\s*\\{(.*)?\\}/mi" ; $ fontRe = "/url\\s*\\(['|\"]?([^)'|\"]*)['|\"]?\\)/i" ; //extract images preg_match_all ( $ imageRe , $ css , $ matches ) ; if ( isset ( $ matches [ 1 ] ) ) { foreach ( $ matches [ 1 ] as $ match ) { $ this -> addAsset ( 'img' , $ match ) ; } } //extract @import preg_match_all ( $ importRe , $ css , $ matches ) ; if ( isset ( $ matches [ 2 ] ) ) { foreach ( $ matches [ 2 ] as $ match ) { $ this -> addAsset ( 'css' , $ match ) ; } } //extract fonts preg_match_all ( $ fontFaceRe , $ css , $ matches ) ; if ( isset ( $ matches [ 1 ] ) ) { foreach ( $ matches [ 1 ] as $ faceMatch ) { preg_match_all ( $ fontRe , $ faceMatch , $ fontMatches ) ; if ( isset ( $ fontMatches [ 1 ] ) ) { foreach ( $ fontMatches [ 1 ] as $ fontMatch ) { $ this -> addAsset ( 'font' , $ fontMatch ) ; } } } } }
Parse, extract and load assets from the stylesheet content
@param string $css the stylesheet content
Parse extract and load assets from the stylesheet content