Skip to content

Commit b5ada18

Browse files
committed
Fix bulk resize not working for non-local filesystems
1 parent 472e61e commit b5ada18

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/jobs/ImageResize.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use verbb\imageresizer\ImageResizer;
55

66
use Craft;
7+
use craft\base\LocalFsInterface;
78
use craft\errors\ElementNotFoundException;
89
use craft\helpers\FileHelper;
910
use craft\helpers\Image;
@@ -56,6 +57,10 @@ public function execute($queue): void
5657
$width = $this->imageWidth;
5758
$height = $this->imageHeight;
5859

60+
$volume = $asset->getVolume();
61+
$fs = $volume->getFs();
62+
$isLocal = $fs instanceof LocalFsInterface;
63+
5964
$result = ImageResizer::$plugin->getResize()->resize($asset, $filename, $path, $width, $height, $this->taskId);
6065

6166
// If the image resize was successful we can continue
@@ -73,6 +78,11 @@ public function execute($queue): void
7378

7479
// Create new record for asset
7580
Craft::$app->getElements()->saveElement($asset);
81+
82+
// For remote file systems, re-saving the asset won't trigger a re-upload of it with altered metadata
83+
if (!$isLocal) {
84+
$volume->write($asset->path, file_get_contents($path));
85+
}
7686
}
7787
}
7888

0 commit comments

Comments
 (0)