summaryrefslogtreecommitdiff
path: root/include/functions.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2020-06-15 11:58:59 +0300
committerAndrew Dolgov <[email protected]>2020-06-15 11:58:59 +0300
commit6eb94f1e1397ae97ed9a0e78d0edc2d04b0915a6 (patch)
tree1e748f20241c05a270ce4324220a29a95edb5bd6 /include/functions.php
parent697418f86387eba775021a745ed65603458cef2b (diff)
better support for image srcset attributes as discussed in https://community.tt-rss.org/t/problem-with-img-srcset/3519
Diffstat (limited to 'include/functions.php')
-rw-r--r--include/functions.php14
1 files changed, 4 insertions, 10 deletions
diff --git a/include/functions.php b/include/functions.php
index 4d54f7e35..16953a0a1 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -1289,19 +1289,13 @@
}
if ($entry->hasAttribute('srcset')) {
- $tokens = explode(",", $entry->getAttribute('srcset'));
+ $matches = RSSUtils::decode_srcset($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";
+ for ($i = 0; $i < count($matches); $i++) {
+ $matches[$i]["url"] = rewrite_relative_url($rewrite_base_url, $matches[$i]["url"]);
}
- $entry->setAttribute("srcset", implode(", ", $tokens));
+ $entry->setAttribute("srcset", RSSUtils::encode_srcset($matches));
}
if ($entry->hasAttribute('src') &&