Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to resolve source image path #1523

Open
tacman opened this issue Aug 3, 2023 · 0 comments
Open

Document how to resolve source image path #1523

tacman opened this issue Aug 3, 2023 · 0 comments

Comments

@tacman
Copy link
Contributor

tacman commented Aug 3, 2023

I would like to get the absolute path of the source image before calling the liip resolver (with the relative path to the image), so that if the image is not there I can dispatch a request to download it.

But I can't figure out how to get that path without re-creating the logic that exists in the Liip Imagine service.

That is, I can get the browser path:

            $url = $this->imageCacheManager->getBrowserPath($relativePath, $filter,
                referenceType: UrlGenerator::ABSOLUTE_PATH
            );

What I want is to get the absolute path.

            $path = $this->imageCacheManager->getSourcePath($relativePath);
            if (!file_exists($path)) $this->downloadImage($relativePath);

I realize that file_exists should be replaced with the Flysystem call, so I guess what may be needed is a way to get the filesystem.

    loaders:
        flysystem_loader:
            flysystem:
                # this comes from flysystem.yaml
                filesystem_service: images_filesystem

    # default loader to use for all filter sets
    data_loader: flysystem_loader
            $loader = $this->imageCacheManager->getLoader();
            // 
            $path = $this->imageCacheManager->getSourcePath($relativePath);
            if (!$loader->fileExists($path)) $this->downloadImage($relativePath);

I've poked around in the code, but the methods I see are private. Is there a way to get what I'm looking for? Since I'm using the local filesystem, I can hack in something that uses the same path that's defined in Flysystem, but that seems precarious.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant