diff options
author | Andrew Dolgov <[email protected]> | 2021-11-18 07:32:28 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-11-18 07:32:28 +0300 |
commit | 63ec5a89657bb7f9650582b96e0bb255a0889b48 (patch) | |
tree | 074b61eedd7304ba1d8d7deec01d26973ef8e6b8 /plugins/af_comics/filters/af_comics_gocomics_farside.php | |
parent | 3a3fde1a2e0beac6d179c6449eaad726100710d7 (diff) | |
parent | 2d830c6281c19a7ee29cd379f5aedc82deef3775 (diff) |
Merge branch 'wip-phpstan-level6'
Diffstat (limited to 'plugins/af_comics/filters/af_comics_gocomics_farside.php')
-rw-r--r-- | plugins/af_comics/filters/af_comics_gocomics_farside.php | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/plugins/af_comics/filters/af_comics_gocomics_farside.php b/plugins/af_comics/filters/af_comics_gocomics_farside.php index 0399015ab..e4e230516 100644 --- a/plugins/af_comics/filters/af_comics_gocomics_farside.php +++ b/plugins/af_comics/filters/af_comics_gocomics_farside.php @@ -50,8 +50,22 @@ class Af_Comics_Gocomics_FarSide extends Af_ComicFilter { if ($content_node) { $imgs = $xpath->query('//img[@data-src]', $content_node); + $cache = new DiskCache("images"); + foreach ($imgs as $img) { - $img->setAttribute('src', $img->getAttribute('data-src')); + $image_url = $img->getAttribute('data-src'); + $local_filename = sha1($image_url); + + if ($image_url) { + $img->setAttribute('src', $image_url); + + // try to cache image locally because they just 401 us otherwise + if (!$cache->exists($local_filename)) { + Debug::log("[Af_Comics_Gocomics_FarSide] caching: $image_url", Debug::LOG_VERBOSE); + $res = $cache->download($image_url, sha1($image_url), ["http_referrer" => $image_url]); + Debug::log("[Af_Comics_Gocomics_FarSide] cache result: $res", Debug::LOG_VERBOSE); + } + } } $junk_elems = $xpath->query("//*[@data-shareable-popover]"); |