]> git.wh0rd.org - tt-rss.git/commitdiff
improve favicon detection (refs #322)
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 24 Mar 2011 10:41:25 +0000 (13:41 +0300)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 24 Mar 2011 10:41:25 +0000 (13:41 +0300)
functions.php

index 01500f3cfa8932a3e68a251a4cce40bbdd87e58d..0dd7ca47bd13cd54ceee4ed5fdb446f3ed29382e 100644 (file)
                        $doc = new DOMDocument();
                        $doc->loadHTML($html);
                        $xpath = new DOMXPath($doc);
-                       $entries = $xpath->query('/html/head/link[@rel="shortcut icon"]');
 
+                       $base = $xpath->query('/html/head/base');
+                       foreach ($base as $b) {
+                               $url = $b->getAttribute("href");
+                               break;
+                       }
+
+                       $entries = $xpath->query('/html/head/link[@rel="shortcut icon" or @rel="icon"]');
                        if (count($entries) > 0) {
                                foreach ($entries as $entry) {
                                        $favicon_url = rewrite_relative_url($url, $entry->getAttribute("href"));
 
                if ($favicon_url && !file_exists($icon_file)) {
                        $contents = fetch_file_contents($favicon_url, "image");
-
                        if ($contents) {
                                $fp = fopen($icon_file, "w");