Skip to content

Commit

Permalink
Merge pull request #62 from rommelfreddy/task/relative-path
Browse files Browse the repository at this point in the history
[FIX] add relative-path of source image to target-path if target is cache-folder
  • Loading branch information
jissereitsma authored Feb 27, 2024
2 parents 5e0e9e5 + 8ea601f commit 3c46376
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Image/TargetImageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ private function getTargetHash(Image $image): string
private function getTargetPathFromImage(Image $image): string
{
if ($this->config->getTargetDirectory() === TargetDirectory::CACHE) {
return $this->config->getCacheDirectoryPath();
$relativeImagePath = str_replace($this->directoryList->getRoot(), '', dirname($image->getPath()));

Check warning on line 90 in Image/TargetImageFactory.php

View workflow job for this annotation

GitHub Actions / Coding Standard

The use of function dirname() is discouraged; use Magento\Framework\Filesystem\DriverInterface::getParentDirectory() instead
$relativeImagePath = str_replace('/pub', '', $relativeImagePath);
$relativeImagePath = preg_replace('#^/#', '', $relativeImagePath); // remove leading slash
return $this->config->getCacheDirectoryPath() . $relativeImagePath;
}

// phpcs:ignore
Expand Down

0 comments on commit 3c46376

Please sign in to comment.