Skip to content

Documented CImage programmatic flow fails because of missing FastTrackCache dependency #185

Description

@lorenzos

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions