summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2017-03-06 09:20:58 +0300
committerAndrew Dolgov <[email protected]>2017-03-06 09:20:58 +0300
commit8519c68d937780bbedf21d8b1d5cb1b37ba91e0e (patch)
treec92181c1414650f36ebfbde2515a1d2addfee8e8 /include
parent270c0a00e5d9c8ce8a120bd48575d36c7ceaca0e (diff)
rewrite relative urls for html5 audio source elements
Diffstat (limited to 'include')
-rw-r--r--include/functions2.php24
1 files changed, 14 insertions, 10 deletions
diff --git a/include/functions2.php b/include/functions2.php
index d68d1ecc3..34f027a55 100644
--- a/include/functions2.php
+++ b/include/functions2.php
@@ -896,7 +896,7 @@
$ttrss_uses_https = parse_url(get_self_url_prefix(), PHP_URL_SCHEME) === 'https';
$rewrite_base_url = $site_url ? $site_url : SELF_URL_PATH;
- $entries = $xpath->query('(//a[@href]|//img[@src]|//video/source[@src])');
+ $entries = $xpath->query('(//a[@href]|//img[@src]|//video/source[@src]|//audio/source[@src])');
foreach ($entries as $entry) {
@@ -910,18 +910,22 @@
if ($entry->hasAttribute('src')) {
$src = rewrite_relative_url($rewrite_base_url, $entry->getAttribute('src'));
- $extension = $entry->tagName == 'source' ? '.mp4' : '.png';
- $cached_filename = CACHE_DIR . '/images/' . sha1($src) . $extension;
+ // check cache only for video and images for the time being
+ if ($entry->nodeName == 'img' || ($entry->parentNode && $entry->parentNode->nodeName == "video")) {
- if (file_exists($cached_filename)) {
- $src = get_self_url_prefix() . '/public.php?op=cached_image&hash=' . sha1($src) . $extension;
+ $extension = $entry->tagName == 'source' ? '.mp4' : '.png';
+ $cached_filename = CACHE_DIR . '/images/' . sha1($src) . $extension;
- if ($entry->hasAttribute('srcset')) {
- $entry->removeAttribute('srcset');
- }
+ if (file_exists($cached_filename)) {
+ $src = get_self_url_prefix() . '/public.php?op=cached_image&hash=' . sha1($src) . $extension;
+
+ if ($entry->hasAttribute('srcset')) {
+ $entry->removeAttribute('srcset');
+ }
- if ($entry->hasAttribute('sizes')) {
- $entry->removeAttribute('sizes');
+ if ($entry->hasAttribute('sizes')) {
+ $entry->removeAttribute('sizes');
+ }
}
}