mirror of
https://github.com/getgrav/grav.git
synced 2026-03-15 17:11:02 +01:00
Fix image memory use (#2045)
* Add a method for freeing the image file, free each derivative after it has been created * Save the scaled derivative on disk before freeing it, store its path
This commit is contained in:
committed by
Andy Miller
parent
3b4296c7a4
commit
da7a93527d
@@ -301,6 +301,8 @@ class ImageMedium extends Medium
|
||||
$derivative->set('width', $width);
|
||||
$derivative->set('height', $height);
|
||||
|
||||
$derivative->saveImage();
|
||||
$derivative->resetImage();
|
||||
$this->addAlternative($ratio, $derivative);
|
||||
}
|
||||
}
|
||||
@@ -559,6 +561,14 @@ class ImageMedium extends Medium
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees the cached image file.
|
||||
*/
|
||||
protected function resetImage()
|
||||
{
|
||||
$this->image = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the image with cache.
|
||||
*
|
||||
@@ -587,7 +597,9 @@ class ImageMedium extends Medium
|
||||
$this->image->merge(ImageFile::open($overlay));
|
||||
}
|
||||
|
||||
return $this->image->cacheFile($this->format, $this->quality);
|
||||
$cachedPath = $this->image->cacheFile($this->format, $this->quality);
|
||||
$this->set('filepath', $cachedPath);
|
||||
return $cachedPath;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user