diff options
author | Andrew Dolgov <[email protected]> | 2017-03-23 15:03:22 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2017-03-23 15:03:22 +0300 |
commit | 48eefd8c5cde204d9c2250fc6e246183f6bc14a1 (patch) | |
tree | 34c8168818a9e5e2cef64c55affe273198aad77e /include | |
parent | 41bead9baa6ae6fa84834ec291167fdc780b1e63 (diff) |
allow caching of audio files
Diffstat (limited to 'include')
-rw-r--r-- | include/functions2.php | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/include/functions2.php b/include/functions2.php index 39c7f746b..9d6eb9330 100644 --- a/include/functions2.php +++ b/include/functions2.php @@ -909,23 +909,17 @@ if ($entry->hasAttribute('src')) { $src = rewrite_relative_url($rewrite_base_url, $entry->getAttribute('src')); + $cached_filename = CACHE_DIR . '/images/' . sha1($src); - // 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_url&hash=' . sha1($src); - $cached_filename = CACHE_DIR . '/images/' . sha1($src); - $extension = $entry->tagName == 'source' ? '.mp4' : '.png'; - - if (file_exists($cached_filename)) { - $src = get_self_url_prefix() . '/public.php?op=cached_url&hash=' . sha1($src) . $extension; - - if ($entry->hasAttribute('srcset')) { - $entry->removeAttribute('srcset'); - } + if ($entry->hasAttribute('srcset')) { + $entry->removeAttribute('srcset'); + } - if ($entry->hasAttribute('sizes')) { - $entry->removeAttribute('sizes'); - } + if ($entry->hasAttribute('sizes')) { + $entry->removeAttribute('sizes'); } } |