summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2018-08-20 14:13:14 +0300
committerAndrew Dolgov <[email protected]>2018-08-20 14:13:14 +0300
commit02bb26a93ff5b60e7bc3236ef3f62c818d32bd12 (patch)
tree7351028a5d72cc0fb514e92a4e84b7a480dd8244 /include
parenta1b86519492c3416b0c848a16b11c92b31f125ff (diff)
rewrite_cached_urls: support video posters
Diffstat (limited to 'include')
-rwxr-xr-xinclude/functions.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/include/functions.php b/include/functions.php
index fe0586678..f03ed3a91 100755
--- a/include/functions.php
+++ b/include/functions.php
@@ -1579,16 +1579,16 @@
$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)) {
@@ -1606,7 +1606,11 @@
$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;
}
}