Skip to content
Snippets Groups Projects
Commit c11f5996 authored by Dorian Merz's avatar Dorian Merz Committed by Robert Lange
Browse files

refs #18290 [finc] add caching for fallback covers

* also removed redundant array-check in Router
parent d1f90f07
No related merge requests found
......@@ -41,6 +41,8 @@ namespace finc\Cover;
*/
class Loader extends \VuFind\Cover\Loader
{
const EMPTY_IMAGE_CONTENT = 'nothing here';
/**
* Flag denoting the last loaded image was a FailImage
*
......@@ -57,9 +59,26 @@ class Loader extends \VuFind\Cover\Loader
public function loadUnavailable()
{
$this->hasLoadedUnavailable = true;
file_put_contents($this->localFile,self::EMPTY_IMAGE_CONTENT);
return parent::loadUnavailable();
}
public function loadImage($settings = [])
{
parent::loadImage($settings);
if ($this->image === self::EMPTY_IMAGE_CONTENT) {
$this->hasLoadedUnavailable = true;
}
}
public function getImage()
{
if ($this->image === self::EMPTY_IMAGE_CONTENT) {
$this->hasLoadedUnavailable = true;
}
return parent::getImage();
}
/**
* Returns true if the last loaded image was the FailImage
*
......
......@@ -98,10 +98,8 @@ class Router implements \Zend\Log\LoggerAwareInterface
if (!$resolveDynamic) {
return null;
}
$settings = is_array($thumb) ? array_merge($thumb, ['size' => $size])
: ['size' => $size];
if ($testLoadImage) {
$this->coverLoader->loadImage($settings);
$this->coverLoader->loadImage(array_merge($thumb, ['size' => $size]));
if ($this->coverLoader->hasLoadedUnavailable()) {
return false;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment