]> git.wh0rd.org Git - tt-rss.git/commitdiff
rewrite_cached_urls: support video posters
authorAndrew Dolgov <noreply@fakecake.org>
Mon, 20 Aug 2018 11:13:14 +0000 (14:13 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Mon, 20 Aug 2018 11:13:14 +0000 (14:13 +0300)
include/functions.php

index fe0586678aaa1b3cc5aca64c55f478bee9e3b860..f03ed3a91eedb6f00a2d8a43b06deb5396b67410 100755 (executable)
                $doc->loadHTML($charset_hack . $res);
                $xpath = new DOMXPath($doc);
 
-               $entries = $xpath->query('(//img[@src]|//video/source[@src]|//audio/source[@src])');
+               $entries = $xpath->query('(//img[@src]|//video[@poster]|//video/source[@src]|//audio/source[@src])');
 
                $need_saving = false;
 
                foreach ($entries as $entry) {
 
-                       if ($entry->hasAttribute('src')) {
+                       if ($entry->hasAttribute('src') || $entry->hasAttribute('poster')) {
 
                                // should be already absolutized because this is called after sanitize()
-                               $src = $entry->getAttribute('src');
+                               $src = $entry->hasAttribute('poster') ? $entry->getAttribute('poster') : $entry->getAttribute('src');
                                $cached_filename = CACHE_DIR . '/images/' . sha1($src);
 
                                if (file_exists($cached_filename)) {
 
                                        $src = get_self_url_prefix() . '/public.php?op=cached_url&hash=' . sha1($src) . $suffix;
 
-                                       $entry->setAttribute('src', $src);
+                                       if ($entry->hasAttribute('poster'))
+                                               $entry->setAttribute('poster', $src);
+                                       else
+                                               $entry->setAttribute('src', $src);
+
                                        $need_saving = true;
                                }
                        }