From 6eb94f1e1397ae97ed9a0e78d0edc2d04b0915a6 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Jun 2020 11:58:59 +0300 Subject: better support for image srcset attributes as discussed in https://community.tt-rss.org/t/problem-with-img-srcset/3519 --- include/functions.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'include/functions.php') 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') && -- cgit v1.2.3