@@ -67,6 +67,8 @@ define([
67
67
* - option-label (string)
68
68
* - option-tooltip-thumb
69
69
* - option-tooltip-value
70
+ * - thumb-width
71
+ * - thumb-height
70
72
*/
71
73
$ . widget ( 'mage.SwatchRendererTooltip' , {
72
74
options : {
@@ -86,6 +88,8 @@ define([
86
88
label = $this . attr ( 'option-label' ) ,
87
89
thumb = $this . attr ( 'option-tooltip-thumb' ) ,
88
90
value = $this . attr ( 'option-tooltip-value' ) ,
91
+ width = $this . attr ( 'thumb-width' ) ,
92
+ height = $this . attr ( 'thumb-height' ) ,
89
93
$image ,
90
94
$title ,
91
95
$corner ;
@@ -115,7 +119,9 @@ define([
115
119
// Image
116
120
$image . css ( {
117
121
'background' : 'url("' + thumb + '") no-repeat center' , //Background case
118
- 'background-size' : 'initial'
122
+ 'background-size' : 'initial' ,
123
+ 'width' : width + 'px' ,
124
+ 'height' : height + 'px'
119
125
} ) ;
120
126
$image . show ( ) ;
121
127
} else if ( type === 1 ) {
@@ -476,6 +482,7 @@ define([
476
482
_RenderSwatchOptions : function ( config , controlId ) {
477
483
var optionConfig = this . options . jsonSwatchConfig [ config . id ] ,
478
484
optionClass = this . options . classes . optionClass ,
485
+ sizeConfig = this . options . jsonSwatchImageSizeConfig ,
479
486
moreLimit = parseInt ( this . options . numberToShow , 10 ) ,
480
487
moreClass = this . options . classes . moreButton ,
481
488
moreText = this . options . moreButtonText ,
@@ -492,6 +499,8 @@ define([
492
499
value ,
493
500
thumb ,
494
501
label ,
502
+ width ,
503
+ height ,
495
504
attr ;
496
505
497
506
if ( ! optionConfig . hasOwnProperty ( this . id ) ) {
@@ -507,6 +516,8 @@ define([
507
516
type = parseInt ( optionConfig [ id ] . type , 10 ) ;
508
517
value = optionConfig [ id ] . hasOwnProperty ( 'value' ) ? optionConfig [ id ] . value : '' ;
509
518
thumb = optionConfig [ id ] . hasOwnProperty ( 'thumb' ) ? optionConfig [ id ] . thumb : '' ;
519
+ width = _ . has ( sizeConfig , 'swatchThumb' ) ? sizeConfig . swatchThumb . width : 110 ;
520
+ height = _ . has ( sizeConfig , 'swatchThumb' ) ? sizeConfig . swatchThumb . height : 90 ;
510
521
label = this . label ? this . label : '' ;
511
522
attr =
512
523
' id="' + controlId + '-item-' + id + '"' +
@@ -519,7 +530,9 @@ define([
519
530
' aria-label="' + label + '"' +
520
531
' option-tooltip-thumb="' + thumb + '"' +
521
532
' option-tooltip-value="' + value + '"' +
522
- ' role="option"' ;
533
+ ' role="option"' +
534
+ ' thumb-width="' + width + '"' +
535
+ ' thumb-height="' + height + '"' ;
523
536
524
537
if ( ! this . hasOwnProperty ( 'products' ) || this . products . length <= 0 ) {
525
538
attr += ' option-empty="true"' ;
@@ -538,7 +551,8 @@ define([
538
551
} else if ( type === 2 ) {
539
552
// Image
540
553
html += '<div class="' + optionClass + ' image" ' + attr +
541
- ' style="background: url(' + value + ') no-repeat center; background-size: initial;">' + '' +
554
+ ' style="background: url(' + value + ') no-repeat center; background-size: initial;width:' +
555
+ sizeConfig . swatchImage . width + 'px; height:' + sizeConfig . swatchImage . height + 'px">' + '' +
542
556
'</div>' ;
543
557
} else if ( type === 3 ) {
544
558
// Clear
0 commit comments