mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 08:15:55 +00:00
better support for image srcset attributes as discussed in https://community.tt-rss.org/t/problem-with-img-srcset/3519
This commit is contained in:
@@ -314,22 +314,19 @@ class DiskCache {
|
||||
}
|
||||
|
||||
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);
|
||||
$cached_filename = sha1($url);
|
||||
for ($i = 0; $i < count($matches); $i++) {
|
||||
$cached_filename = sha1($matches[$i]["url"]);
|
||||
|
||||
if ($cache->exists($cached_filename)) {
|
||||
$tokens[$i] = $cache->getUrl($cached_filename) . " " . $width;
|
||||
$matches[$i]["url"] = $cache->getUrl($cached_filename);
|
||||
|
||||
$need_saving = true;
|
||||
}
|
||||
}
|
||||
|
||||
$entry->setAttribute("srcset", implode(", ", $tokens));
|
||||
$entry->setAttribute("srcset", RSSUtils::encode_srcset($matches));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user