Skip to content

Commit

Permalink
Fix bulk resize not working for non-local filesystems
Browse files Browse the repository at this point in the history
  • Loading branch information
engram-design committed Jan 27, 2024
1 parent 472e61e commit b5ada18
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/jobs/ImageResize.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use verbb\imageresizer\ImageResizer;

use Craft;
use craft\base\LocalFsInterface;
use craft\errors\ElementNotFoundException;
use craft\helpers\FileHelper;
use craft\helpers\Image;
Expand Down Expand Up @@ -56,6 +57,10 @@ public function execute($queue): void
$width = $this->imageWidth;
$height = $this->imageHeight;

$volume = $asset->getVolume();
$fs = $volume->getFs();
$isLocal = $fs instanceof LocalFsInterface;

$result = ImageResizer::$plugin->getResize()->resize($asset, $filename, $path, $width, $height, $this->taskId);

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

// Create new record for asset
Craft::$app->getElements()->saveElement($asset);

// For remote file systems, re-saving the asset won't trigger a re-upload of it with altered metadata
if (!$isLocal) {
$volume->write($asset->path, file_get_contents($path));
}
}
}

Expand Down

0 comments on commit b5ada18

Please sign in to comment.