@@ -193,9 +193,15 @@ public function resizeFromThemes(?array $themes = null, bool $skipHiddenImages =
193
193
foreach ($ productImages as $ image ) {
194
194
$ error = '' ;
195
195
$ originalImageName = $ image ['filepath ' ];
196
+
196
197
$ websiteIds = isset ($ image ['website_ids ' ])
197
198
? array_map ('intval ' , explode (', ' , $ image ['website_ids ' ]))
198
199
: [];
200
+ $ relevantViewImages = $ skipHiddenImages ? array_filter (
201
+ $ viewImages ,
202
+ fn ($ index ) => array_intersect ($ this ->paramsWebsitesMap [$ index ], $ websiteIds ),
203
+ ARRAY_FILTER_USE_KEY
204
+ ) : $ viewImages ;
199
205
200
206
$ mediastoragefilename = $ this ->imageConfig ->getMediaPath ($ originalImageName );
201
207
$ originalImagePath = $ this ->mediaDirectory ->getAbsolutePath ($ mediastoragefilename );
@@ -205,11 +211,7 @@ public function resizeFromThemes(?array $themes = null, bool $skipHiddenImages =
205
211
}
206
212
if ($ this ->mediaDirectory ->isFile ($ originalImagePath )) {
207
213
try {
208
- foreach ($ viewImages as $ index => $ viewImage ) {
209
- if ($ skipHiddenImages && !array_intersect ($ this ->paramsWebsitesMap [$ index ], $ websiteIds )) {
210
- continue ;
211
- }
212
-
214
+ foreach ($ relevantViewImages as $ viewImage ) {
213
215
$ this ->resize ($ viewImage , $ originalImagePath , $ originalImageName );
214
216
}
215
217
} catch (\Exception $ e ) {
@@ -224,6 +226,8 @@ public function resizeFromThemes(?array $themes = null, bool $skipHiddenImages =
224
226
}
225
227
226
228
/**
229
+ * Get count of product images.
230
+ *
227
231
* @param bool $skipHiddenImages
228
232
* @return int
229
233
*/
@@ -234,6 +238,8 @@ public function getCountProductImages(bool $skipHiddenImages = false): int
234
238
}
235
239
236
240
/**
241
+ * Get product images.
242
+ *
237
243
* @param bool $skipHiddenImages
238
244
* @return Generator
239
245
*/
0 commit comments