File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed
ConfigurableProduct/view/frontend/web/js
Swatches/view/frontend/web/js Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -291,6 +291,7 @@ define([
291
291
images = this . options . spConfig . images [ this . simpleProduct ] ;
292
292
293
293
if ( images ) {
294
+ images = this . _sortImages ( images ) ;
294
295
if ( this . options . gallerySwitchStrategy === 'prepend' ) {
295
296
images = images . concat ( initialImages ) ;
296
297
}
@@ -309,7 +310,17 @@ define([
309
310
$ ( this . options . mediaGallerySelector ) . AddFotoramaVideoEvents ( ) ;
310
311
}
311
312
312
- galleryObject . first ( ) ;
313
+ } ,
314
+
315
+ /**
316
+ * Sorting images array
317
+ *
318
+ * @private
319
+ */
320
+ _sortImages : function ( images ) {
321
+ return _ . sortBy ( images , function ( image ) {
322
+ return image . position ;
323
+ } ) ;
313
324
} ,
314
325
315
326
/**
Original file line number Diff line number Diff line change @@ -695,7 +695,7 @@ define([
695
695
*/
696
696
_sortImages : function ( images ) {
697
697
return _ . sortBy ( images , function ( image ) {
698
- return image . isMain === true ? - 1 : image . position ;
698
+ return image . position ;
699
699
} ) ;
700
700
} ,
701
701
@@ -1243,9 +1243,6 @@ define([
1243
1243
dataMergeStrategy : this . options . gallerySwitchStrategy
1244
1244
} ) ;
1245
1245
}
1246
-
1247
- gallery . first ( ) ;
1248
-
1249
1246
} else if ( justAnImage && justAnImage . img ) {
1250
1247
context . find ( '.product-image-photo' ) . attr ( 'src' , justAnImage . img ) ;
1251
1248
}
Original file line number Diff line number Diff line change @@ -472,8 +472,16 @@ define([
472
472
* @param {Array.<Object> } data - Set of gallery items to update.
473
473
*/
474
474
updateData : function ( data ) {
475
+ var mainImageIndex ;
475
476
if ( _ . isArray ( data ) ) {
476
477
settings . fotoramaApi . load ( data ) ;
478
+ mainImageIndex = getMainImageIndex ( data ) ;
479
+ if ( mainImageIndex ) {
480
+ settings . fotoramaApi . show ( {
481
+ index : mainImageIndex ,
482
+ time : 0
483
+ } ) ;
484
+ }
477
485
478
486
$ . extend ( false , settings , {
479
487
data : data ,
You can’t perform that action at this time.
0 commit comments