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

If Volume includes Subpath, new asset is generated every time #25

Open
rogerdawkins opened this issue Jul 17, 2024 · 0 comments
Open

If Volume includes Subpath, new asset is generated every time #25

rogerdawkins opened this issue Jul 17, 2024 · 0 comments

Comments

@rogerdawkins
Copy link

I have the following simple setup:
Filesystem: Images (local folder)
Base URL: @web/assets/img

Asset Volume: Thumbnails which uses the above FS
Subpath: thumbnails

If the Subpath is not set then PDF Transform works fine, but with the Subpath set then PDF Transform generates a new Asset always, i.e. it doesn't use the previously generated image.

The reason appears to be in the render function (PdfTransformService.php) as below:

$volume = $this->getImageVolume();
$fs = $this->getImageFs();
$fileName = $this->getFileName($asset);

if ($fs->fileExists($fileName)) {

  $transformedAsset = Asset::find()
    ->volumeId($volume->id)
    ->filename($fileName)
    ->one();

  return $transformedAsset;
}

The issue is that the fileExists is being checked against the filesystem which is only the basepath and doesn't include the subpath. If the $fs->fileExists is changed to $volume->fileExists then the full path is used and the generated image is returned rather than a new asset.

Do you want me to create a PR?

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