summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2011-03-24 13:41:25 +0300
committerAndrew Dolgov <[email protected]>2011-03-24 13:41:25 +0300
commita712429edcd201341483cc3a85364bd6540769be (patch)
tree5cb51876672733f5b010541b51540d66f733ac79
parent1b24f3319abe031307786eeb7e9223776c2d8cf1 (diff)
improve favicon detection (refs #322)
-rw-r--r--functions.php9
1 files changed, 7 insertions, 2 deletions
diff --git a/functions.php b/functions.php
index 01500f3cf..0dd7ca47b 100644
--- a/functions.php
+++ b/functions.php
@@ -427,8 +427,14 @@
$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"));
@@ -452,7 +458,6 @@
if ($favicon_url && !file_exists($icon_file)) {
$contents = fetch_file_contents($favicon_url, "image");
-
if ($contents) {
$fp = fopen($icon_file, "w");