From dcbcae32e7c5e7c334383756517245d5f4baba9a Mon Sep 17 00:00:00 2001 From: philipp lang Date: Tue, 15 Feb 2022 18:05:53 +0100 Subject: [PATCH] Fetch compressor only once during resize --- classes/ImageResizer.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/classes/ImageResizer.php b/classes/ImageResizer.php index 9d02241..9194878 100644 --- a/classes/ImageResizer.php +++ b/classes/ImageResizer.php @@ -90,8 +90,10 @@ class ImageResizer private function generateVersions(): void { + $compressor = $this->file->compressor(); + foreach ($this->possibleSizes() as $size) { - $this->file->compressor()->resize($size, $this->update, function($media, $file) { + $compressor->resize($size, $this->update, function($media, $file) { if (!file_exists($file)) { throw new ResizerException('File versions cannot be generated. Version file "'.$file.'" of "'.$this->file->root().'" doesnt exist.'); }