diff options
author | lllusion3418 <[email protected]> | 2020-03-12 11:08:24 +0100 |
---|---|---|
committer | lllusion3418 <[email protected]> | 2020-03-12 11:08:24 +0100 |
commit | b4287a2e986f409044baf2ce9965f20cff3a7986 (patch) | |
tree | c317119b01faf813d13f8d45b2c1d9e239386d77 | |
parent | 208e02c47d086b67f1431a9e09c76a8129ac8939 (diff) |
fix url rewriting for videos with poster and src
if a poster attribute was present only that would have been rewritten
and the (arguably more important) src attribute would be left as-is
-rw-r--r-- | classes/diskcache.php | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/classes/diskcache.php b/classes/diskcache.php index 7e4a8335d..ad775ac11 100644 --- a/classes/diskcache.php +++ b/classes/diskcache.php @@ -95,24 +95,21 @@ class DiskCache { foreach ($entries as $entry) { - if ($entry->hasAttribute('src') || $entry->hasAttribute('poster')) { + foreach (array('src', 'poster') as $attr) { + if ($entry->hasAttribute($attr)) { + // should be already absolutized because this is called after sanitize() + $src = $entry->getAttribute($attr); + $cached_filename = sha1($src); - // should be already absolutized because this is called after sanitize() - $src = $entry->hasAttribute('poster') ? $entry->getAttribute('poster') : $entry->getAttribute('src'); - $cached_filename = sha1($src); + if ($cache->exists($cached_filename)) { - if ($cache->exists($cached_filename)) { + $src = $cache->getUrl(sha1($src)); - $src = $cache->getUrl(sha1($src)); - - if ($entry->hasAttribute('poster')) - $entry->setAttribute('poster', $src); - else { - $entry->setAttribute('src', $src); + $entry->setAttribute($attr, $src); $entry->removeAttribute("srcset"); - } - $need_saving = true; + $need_saving = true; + } } } } |