allow caching of audio files

This commit is contained in:
Andrew Dolgov 2017-03-23 15:03:22 +03:00
parent 41bead9baa
commit 48eefd8c5c
1 changed files with 8 additions and 14 deletions

View File

@ -909,23 +909,17 @@
if ($entry->hasAttribute('src')) { if ($entry->hasAttribute('src')) {
$src = rewrite_relative_url($rewrite_base_url, $entry->getAttribute('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 (file_exists($cached_filename)) {
if ($entry->nodeName == 'img' || ($entry->parentNode && $entry->parentNode->nodeName == "video")) { $src = get_self_url_prefix() . '/public.php?op=cached_url&hash=' . sha1($src);
$cached_filename = CACHE_DIR . '/images/' . sha1($src); if ($entry->hasAttribute('srcset')) {
$extension = $entry->tagName == 'source' ? '.mp4' : '.png'; $entry->removeAttribute('srcset');
}
if (file_exists($cached_filename)) { if ($entry->hasAttribute('sizes')) {
$src = get_self_url_prefix() . '/public.php?op=cached_url&hash=' . sha1($src) . $extension; $entry->removeAttribute('sizes');
if ($entry->hasAttribute('srcset')) {
$entry->removeAttribute('srcset');
}
if ($entry->hasAttribute('sizes')) {
$entry->removeAttribute('sizes');
}
} }
} }