@@ -99,6 +99,10 @@ class Resize
99
99
* @var string $absolutePathoriginal
100
100
*/
101
101
protected $ absolutePathoriginal ;
102
+ /**
103
+ * @var array $tempCache
104
+ */
105
+ protected $ tempCache = [];
102
106
/**
103
107
* @var array
104
108
*
@@ -208,10 +212,15 @@ public function __construct(
208
212
*
209
213
* @return string
210
214
*/
211
- public function resizeAndGetUrl (string $ imagePath , $ width , $ height , array $ resizeSettings = [], string $ format = null ): string
215
+ public function resizeAndGetUrl (string $ imagePath , $ width , $ height , array $ resizeSettings = [], ? string $ format = null ): string
212
216
{
213
- $ cacheKey = md5 ($ imagePath . '- ' . $ width . '- ' . $ height . '- ' . json_encode ($ resizeSettings ));
217
+ $ cacheKey = md5 ($ imagePath . '- ' . $ width . '- ' . $ height . '- ' . json_encode ($ resizeSettings ) . '- ' . (string )$ format );
218
+ if (isset ($ this ->tempCache [$ cacheKey ])) {
219
+ return $ this ->tempCache [$ cacheKey ];
220
+ }
221
+
214
222
if ($ resultUrl = $ this ->cache ->load ($ cacheKey )) {
223
+ $ this ->tempCache [$ cacheKey ] = $ resultUrl ;
215
224
return $ resultUrl ;
216
225
}
217
226
@@ -270,6 +279,7 @@ public function resizeAndGetUrl(string $imagePath, $width, $height, array $resiz
270
279
}
271
280
272
281
$ this ->cache ->save ($ resultUrl , $ cacheKey , [self ::CACHE_TAG_IDENTIFIER ]);
282
+ $ this ->tempCache [$ cacheKey ] = $ resultUrl ;
273
283
} catch (\Exception $ e ) {
274
284
$ this ->logger ->error ("Web200_ImageResize: could not resize image: " .$ imagePath ." \n" . $ e ->getMessage ());
275
285
}
0 commit comments