From cf7da1d41ca50ee9c772a469a83b1164da1c88cc Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sat, 18 Feb 2017 13:40:58 +0100 Subject: [PATCH] [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. --- lib/html.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/html.php b/lib/html.php index 24a2cab4..8eb0deb3 100644 --- a/lib/html.php +++ b/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; }