cimage icon indicating copy to clipboard operation
cimage copied to clipboard

Documented CImage programmatic flow fails because of missing FastTrackCache dependency

Open lorenzos opened this issue 3 years ago • 0 comments

I needed to use CImage class API to make and cache thumbnails programmatically, and I found the useful "How it all works" page on the website. That page shows an example flow that I think it always fails because of missing FastTrackCache dependency.

I looked at the FastTrackCache-related code, and I had the impression that it was once optional; now it seems that CImage doesn't work without it: the programmatic flow, as shown, fails with a NPE here. Am I wrong?

Looking at img.php here, here's how I fixed the programmatic flow:


$cachePath = '/my/cache/path/';
$fastTrackCachePath = $cachePath . 'fasttrack/';
@mkdir($fastTrackCachePath, 0777);
$fastTrackCache = new CFastTrackCache();
$fastTrackCache->setCacheDir($fastTrackCachePath)->enable(true)->setFilename(['no-cache', 'nc']);

// https://cimage.se/doc/cimage-api
$cimage = new CImage();
$cimage->useCache(true)->setSaveFolder($cachePath)->injectDependency("fastTrackCache", $fastTrackCache);
// ...etc

lorenzos avatar Dec 10 '21 15:12 lorenzos