From 8ea601fd3d1765f76d9cb8af93c1e57421121c22 Mon Sep 17 00:00:00 2001 From: Frederik Rommel Date: Fri, 30 Jun 2023 17:23:32 +0200 Subject: [PATCH] [FIX ] add relative-path of source image to target-path if target is cache-folder --- Image/TargetImageFactory.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Image/TargetImageFactory.php b/Image/TargetImageFactory.php index 35cdaf4..6599839 100644 --- a/Image/TargetImageFactory.php +++ b/Image/TargetImageFactory.php @@ -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())); + $relativeImagePath = str_replace('/pub', '', $relativeImagePath); + $relativeImagePath = preg_replace('#^/#', '', $relativeImagePath); // remove leading slash + return $this->config->getCacheDirectoryPath() . $relativeImagePath; } // phpcs:ignore