From f346312266872dbba4671809fd822ab7b79080ca Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Sat, 15 Aug 2020 00:55:17 -0600 Subject: [PATCH] Minor improvements --- modules/system/classes/ImageResizer.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/system/classes/ImageResizer.php b/modules/system/classes/ImageResizer.php index c258fd2b2..9fd243291 100644 --- a/modules/system/classes/ImageResizer.php +++ b/modules/system/classes/ImageResizer.php @@ -26,7 +26,7 @@ use October\Rain\Database\Attach\Resizer as DefaultResizer; * 'crop', // crop to the given dimensions after fitting as much of the image as possible inside those * 'fit', // fit the image inside the given maximal dimensions, keeping the aspect ratio * ], - * 'quality' => numeric, 1 - 100 + * 'quality' => numeric, 1 - 100 * 'interlace' => boolean (default false), * 'extension' => ['auto', 'png', 'gif', 'jpg', 'jpeg', 'webp', 'bmp', 'ico'], * 'offset' => [x, y] Offset to crop the image from @@ -107,6 +107,11 @@ class ImageResizer */ public const CACHE_PREFIX = 'system.resizer.'; + /** + * @var array Available sources to get images from + */ + protected static $availableSources = []; + /** * @var string Unique identifier for the current configuration */ @@ -196,6 +201,10 @@ class ImageResizer */ public static function getAvailableSources() { + if (!empty(static::$availableSources)) { + return static::$availableSources; + } + $sources = [ 'themes' => [ 'disk' => 'system', @@ -241,7 +250,7 @@ class ImageResizer */ Event::fire('system.resizer.getAvailableSources', [&$sources]); - return $sources; + return static::$availableSources = $sources; } /** @@ -743,7 +752,7 @@ class ImageResizer { // Attempt to process the provided image try { - $resizer = new ImageResizer($image, $width, $height, $options); + $resizer = new static($image, $width, $height, $options); } catch (SystemException $ex) { // Ignore processing this URL if the resizer is unable to identify it if (is_string($image)) { @@ -757,4 +766,4 @@ class ImageResizer return $resizer->getUrl(); } -} +} \ No newline at end of file