summaryrefslogtreecommitdiff
path: root/include/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/functions.php')
-rw-r--r--include/functions.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/include/functions.php b/include/functions.php
index c223a3db8..532e48139 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -1264,7 +1264,7 @@
$rewrite_base_url = $site_url ? $site_url : get_self_url_prefix();
- $entries = $xpath->query('(//a[@href]|//img[@src]|//video/source[@src]|//audio/source[@src]|//picture/source[@src])');
+ $entries = $xpath->query('(//a[@href]|//img[@src]|//video/source[@src]|//audio/source[@src]|//picture/source[@src]|//picture/source[@srcset])');
foreach ($entries as $entry) {
@@ -1303,6 +1303,22 @@
}
}
+ if ($entry->hasAttribute('srcset')) {
+ $tokens = explode(",", $entry->getAttribute('srcset'));
+
+ for ($i = 0; $i < count($tokens); $i++) {
+ $token = trim($tokens[$i]);
+
+ list ($url, $width) = explode(" ", $token, 2);
+
+ $url = rewrite_relative_url($rewrite_base_url, $url);
+
+ $tokens[$i] = "$url $width";
+ }
+
+ $entry->setAttribute("srcset", implode(", ", $tokens));
+ }
+
if ($entry->hasAttribute('src') &&
($owner && get_pref("STRIP_IMAGES", $owner)) || $force_remove_images || $_SESSION["bw_limit"]) {