Fetch compressor only once during resize

This commit is contained in:
philipp lang 2022-02-15 18:05:53 +01:00
parent f419888ec6
commit dcbcae32e7
1 changed files with 3 additions and 1 deletions

View File

@ -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.');
}