diff --git a/system/src/Grav/Common/Page/Medium/ImageMedium.php b/system/src/Grav/Common/Page/Medium/ImageMedium.php index 05bc4c486..8be914e12 100644 --- a/system/src/Grav/Common/Page/Medium/ImageMedium.php +++ b/system/src/Grav/Common/Page/Medium/ImageMedium.php @@ -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; } /**