mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 01:46:00 +00:00
add DiskCache.getUrl() and use it in a bunch of places
This commit is contained in:
@@ -676,7 +676,7 @@ class Article extends Handler_Protected {
|
|||||||
while ($line = $sth->fetch()) {
|
while ($line = $sth->fetch()) {
|
||||||
|
|
||||||
if (file_exists(CACHE_DIR . '/images/' . sha1($line["content_url"]))) {
|
if (file_exists(CACHE_DIR . '/images/' . sha1($line["content_url"]))) {
|
||||||
$line["content_url"] = get_self_url_prefix() . '/public.php?op=cached_url&hash=' . sha1($line["content_url"]);
|
$line["content_url"] = DiskCache::getUrl(sha1($line["content_url"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
array_push($rv, $line);
|
array_push($rv, $line);
|
||||||
|
|||||||
@@ -56,4 +56,8 @@ class DiskCache {
|
|||||||
public function send($filename) {
|
public function send($filename) {
|
||||||
return send_local_file($this->getFullPath($filename));
|
return send_local_file($this->getFullPath($filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public function getUrl($filename) {
|
||||||
|
return get_self_url_prefix() . "/public.php?op=cached_url&file=" . $filename;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1202,7 +1202,7 @@ class Handler_Public extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cached_url() {
|
function cached_url() {
|
||||||
@$req_filename = basename($_GET['hash']);
|
@$req_filename = basename($_GET['file']);
|
||||||
|
|
||||||
// we don't need an extension to find the file, hash is a complete URL
|
// we don't need an extension to find the file, hash is a complete URL
|
||||||
$hash = preg_replace("/\.[^\.]*$/", "", $req_filename);
|
$hash = preg_replace("/\.[^\.]*$/", "", $req_filename);
|
||||||
|
|||||||
@@ -1258,20 +1258,7 @@
|
|||||||
|
|
||||||
if (file_exists($cached_filename)) {
|
if (file_exists($cached_filename)) {
|
||||||
|
|
||||||
// this is strictly cosmetic
|
$src = DiskCache::getUrl(sha1($src));
|
||||||
if ($entry->tagName == 'img') {
|
|
||||||
$suffix = ".png";
|
|
||||||
} else if ($entry->parentNode && $entry->parentNode->tagName == "picture") {
|
|
||||||
$suffix = ".png";
|
|
||||||
} else if ($entry->parentNode && $entry->parentNode->tagName == "video") {
|
|
||||||
$suffix = ".mp4";
|
|
||||||
} else if ($entry->parentNode && $entry->parentNode->tagName == "audio") {
|
|
||||||
$suffix = ".ogg";
|
|
||||||
} else {
|
|
||||||
$suffix = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
$src = get_self_url_prefix() . '/public.php?op=cached_url&hash=' . sha1($src) . $suffix;
|
|
||||||
|
|
||||||
if ($entry->hasAttribute('poster'))
|
if ($entry->hasAttribute('poster'))
|
||||||
$entry->setAttribute('poster', $src);
|
$entry->setAttribute('poster', $src);
|
||||||
|
|||||||
Reference in New Issue
Block a user