public function removeImports($data, $cssUrl)
 {
     $sBaseUrl = dirname($cssUrl) . '/';
     $config = $this->config;
     $config['css_url'] = $cssUrl;
     $self = $this;
     return preg_replace_callback('/@import url\\(([^)]+)\\)(;?)/', function ($aMatches) use($sBaseUrl, $config, $self) {
         $url = Url::normalizeUrl(str_replace(array('"', '\''), '', trim($aMatches[1])));
         return $self::removeImports($self->fixUrl(File::get_content($url), $url), $url);
     }, $data);
 }
 private function removeHttpProtocol()
 {
     $scripts = array('img', 'link', 'script');
     $attr = array('src', 'href', 'data-ll');
     foreach ($scripts as $script) {
         $html = $this->DOMHtml->getContent();
         $regex = '/<' . $script . '((?:.)*?)>/smix';
         $content = preg_replace_callback($regex, function ($srcpt) use($attr, $script) {
             $regex_img = '/(\\S+)=["\']((?:.(?!["\']?\\s+(?:\\S+)=|[>"\']))+.)["\']/';
             preg_match_all($regex_img, $srcpt[1], $matches);
             if (isset($matches[1]) && isset($matches[2])) {
                 foreach ($matches[1] as $k => $key) {
                     $attributes[trim($key)] = trim($matches[2][$k]);
                 }
             }
             if (isset($attributes) && is_array($attributes)) {
                 foreach ($attr as $att) {
                     if (isset($attributes[$att]) && $attributes[$att]) {
                         $attributes[$att] = Url::normalizeUrl($attributes[$att]);
                     }
                 }
                 $return = '<' . $script;
                 foreach ($attributes as $key => $a) {
                     $return .= ' ' . $key . '="' . $a . '"';
                 }
                 $return .= '>';
                 return $return;
             } else {
                 return $srcpt[0];
             }
         }, $html);
         $this->DOMHtml->setContent($content ?: $html);
     }
 }
 protected function get_data($url)
 {
     if (is_file($this->config['BasePath'] . Url::normalizeUrl($url))) {
         $url = $this->config['BasePath'] . Url::normalizeUrl($url);
         try {
             $data = File::get_content($url);
         } catch (Exception $ex) {
         }
     } else {
         if (is_file($this->config['BasePath'] . $url)) {
             $data = File::get_content($this->config['BasePath'] . $url);
         } else {
             $data = File::get_content($url);
         }
     }
     return $data;
 }
 public static function normalizeAttributes(array $attributes = array())
 {
     foreach ($attributes as $key => $att) {
         if (strtolower($key) == 'class') {
             $att = $att . ' ' . self::$config['LazyLoadClass'];
         }
         if (strtolower($key) == 'src') {
             $att = Url::normalizeUrl($att);
             $return['img'] .= ' ' . $key . '="' . $att . '"';
             $return['lazy_img'] .= ' ' . $key . '="' . self::$config['LazyLoadPlaceHolder'] . '"';
             $key = 'data-ll';
         } else {
             $return['img'] .= ' ' . $key . '="' . $att . '"';
         }
         if (!in_array(strtolower($key), self::$config['LazyLoadOnlyOnNoScript'])) {
             $return['lazy_img'] .= ' ' . $key . '="' . $att . '"';
         }
     }
     if (!array_key_exists('class', $attributes)) {
         $return['img'] .= ' class="' . self::$config['LazyLoadClass'] . '"';
     }
     return $return;
 }