1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-13 22:35:55 +00:00

image cache: do not try to cache data: schema urls; add caching of html5 video content (similar to cache_starred_images plugin)

This commit is contained in:
Andrew Dolgov
2017-02-04 11:50:01 +03:00
parent 0442cbb6c1
commit 5edd605ae1
3 changed files with 23 additions and 20 deletions

View File

@@ -1239,13 +1239,14 @@
$doc->loadHTML($charset_hack . $html);
$xpath = new DOMXPath($doc);
$entries = $xpath->query('(//img[@src])');
$entries = $xpath->query('(//img[@src])|(//video/source[@src])');
foreach ($entries as $entry) {
if ($entry->hasAttribute('src')) {
if ($entry->hasAttribute('src') && strpos($entry->getAttribute('src'), "data:") !== 0) {
$src = rewrite_relative_url($site_url, $entry->getAttribute('src'));
$local_filename = CACHE_DIR . "/images/" . sha1($src) . ".png";
$extension = $entry->tagName == 'source' ? '.mp4' : '.png';
$local_filename = CACHE_DIR . "/images/" . sha1($src) . $extension;
if ($debug) _debug("cache_images: downloading: $src to $local_filename");