Browse Source

[html] Fix anchors after fixing images

Anchors will be fixed in a similar way as it is done with images,
so it can be done in one go.
logmanoriginal 7 years ago
parent
commit
cf7da1d41c
1 changed files with 9 additions and 0 deletions
  1. 9 0
      lib/html.php

+ 9 - 0
lib/html.php

@@ -285,5 +285,14 @@ function defaultImageSrcTo($content, $server){
 		&& strpos($image->src, 'data:') === false)
 			$image->src = $server . $image->src;
 	}
+
+	foreach($content->find('a') as $anchor){
+		if(strpos($anchor->href, 'http') === false
+		&& strpos($anchor->href, '//') === false
+		&& strpos($anchor->href, '#') !== 0
+		&& strpos($anchor->href, '?') !== 0)
+			$anchor->href = $server . $anchor->href;
+	}
+
 	return $content;
 }