@@ -193,9 +193,15 @@ public function resizeFromThemes(?array $themes = null, bool $skipHiddenImages =
193193 foreach ($ productImages as $ image ) {
194194 $ error = '' ;
195195 $ originalImageName = $ image ['filepath ' ];
196+
196197 $ websiteIds = isset ($ image ['website_ids ' ])
197198 ? array_map ('intval ' , explode (', ' , $ image ['website_ids ' ]))
198199 : [];
200+ $ relevantViewImages = $ skipHiddenImages ? array_filter (
201+ $ viewImages ,
202+ fn ($ index ) => array_intersect ($ this ->paramsWebsitesMap [$ index ], $ websiteIds ),
203+ ARRAY_FILTER_USE_KEY
204+ ) : $ viewImages ;
199205
200206 $ mediastoragefilename = $ this ->imageConfig ->getMediaPath ($ originalImageName );
201207 $ originalImagePath = $ this ->mediaDirectory ->getAbsolutePath ($ mediastoragefilename );
@@ -205,11 +211,7 @@ public function resizeFromThemes(?array $themes = null, bool $skipHiddenImages =
205211 }
206212 if ($ this ->mediaDirectory ->isFile ($ originalImagePath )) {
207213 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 ) {
213215 $ this ->resize ($ viewImage , $ originalImagePath , $ originalImageName );
214216 }
215217 } catch (\Exception $ e ) {
@@ -224,6 +226,8 @@ public function resizeFromThemes(?array $themes = null, bool $skipHiddenImages =
224226 }
225227
226228 /**
229+ * Get count of product images.
230+ *
227231 * @param bool $skipHiddenImages
228232 * @return int
229233 */
@@ -234,6 +238,8 @@ public function getCountProductImages(bool $skipHiddenImages = false): int
234238 }
235239
236240 /**
241+ * Get product images.
242+ *
237243 * @param bool $skipHiddenImages
238244 * @return Generator
239245 */
0 commit comments