@@ -85,7 +85,7 @@ const AssetEdit = {
8585 this . imageOverlayMap = [
8686 { key : 'imageId' , input : this . imageOverlayImageIdInput , defaultValue : '' , event : 'input' } ,
8787 { key : 'publicId' , input : this . imageOverlayPublicIdInput , defaultValue : '' , event : 'input' } ,
88- { key : 'size' , input : this . imageOverlaySizeInput , defaultValue : 100 , event : 'input' } ,
88+ { key : 'size' , input : this . imageOverlaySizeInput , defaultValue : 20 , event : 'input' } ,
8989 { key : 'opacity' , input : this . imageOverlayOpacityInput , defaultValue : 20 , event : 'input' } ,
9090 { key : 'position' , input : this . imageOverlayPositionInput , defaultValue : '' , event : 'change' } ,
9191 { key : 'xOffset' , input : this . imageOverlayXOffsetInput , defaultValue : 0 , event : 'input' } ,
@@ -376,6 +376,7 @@ const AssetEdit = {
376376 this . textOverlayMap . forEach ( ( { input, defaultValue } ) => {
377377 if ( input ) {
378378 input . value = defaultValue ;
379+ input . dispatchEvent ( new Event ( 'change' ) ) ;
379380 }
380381 } ) ;
381382
@@ -393,6 +394,7 @@ const AssetEdit = {
393394 this . imageOverlayMap . forEach ( ( { input, defaultValue } ) => {
394395 if ( input ) {
395396 input . value = defaultValue ;
397+ input . dispatchEvent ( new Event ( 'change' ) ) ;
396398 }
397399 } ) ;
398400
@@ -411,6 +413,10 @@ const AssetEdit = {
411413 // Update preview to remove image overlay
412414 this . preview . setSrc ( this . buildSrc ( ) ) ;
413415 } ,
416+ getFormattedPercentageValue ( value ) {
417+ const val = value / 100 ;
418+ return val % 1 === 0 ? val . toFixed ( 1 ) : val ;
419+ } ,
414420 buildPlacementQualifiers ( positionInput , xOffsetInput , yOffsetInput ) {
415421 let placementQualifiers = [ ] ;
416422
@@ -419,11 +425,11 @@ const AssetEdit = {
419425 }
420426
421427 if ( xOffsetInput ?. value ) {
422- placementQualifiers . push ( `x_${ xOffsetInput . value } ` ) ;
428+ placementQualifiers . push ( `x_${ this . getFormattedPercentageValue ( xOffsetInput . value ) } ` ) ;
423429 }
424430
425431 if ( yOffsetInput ?. value ) {
426- placementQualifiers . push ( `y_${ yOffsetInput . value } ` ) ;
432+ placementQualifiers . push ( `y_${ this . getFormattedPercentageValue ( yOffsetInput . value ) } ` ) ;
427433 }
428434
429435 return placementQualifiers . length > 0 ? ',' + placementQualifiers . join ( ',' ) : '' ;
@@ -440,7 +446,7 @@ const AssetEdit = {
440446 let transformations = [ ] ;
441447
442448 if ( this . imageOverlaySizeInput ?. value ) {
443- transformations . push ( `c_scale,w_${ this . imageOverlaySizeInput . value } ` ) ;
449+ transformations . push ( `c_scale,w_${ this . getFormattedPercentageValue ( this . imageOverlaySizeInput . value ) } ` ) ;
444450 }
445451
446452 if ( this . imageOverlayOpacityInput ?. value ) {
@@ -457,7 +463,7 @@ const AssetEdit = {
457463 this . imageOverlayYOffsetInput
458464 ) ;
459465
460- return `${ imageLayerDefinition } /fl_layer_apply${ placementString } ` ;
466+ return `${ imageLayerDefinition } /c_limit,w_1.0,fl_relative/ fl_layer_apply${ placementString } ` ;
461467 } ,
462468 buildTextOverlay ( ) {
463469 if ( ! this . textOverlayTextInput || ! this . textOverlayTextInput . value . trim ( ) ) {
@@ -505,7 +511,7 @@ const AssetEdit = {
505511 this . textOverlayYOffsetInput
506512 ) ;
507513
508- return `${ textLayerDefinition } /fl_layer_apply${ placementString } ` ;
514+ return `${ textLayerDefinition } /c_limit,w_0.9,fl_relative/ fl_layer_apply${ placementString } ` ;
509515 } ,
510516 buildSrc ( ) {
511517 const transformations = this . transformationsInput . value ;
@@ -591,11 +597,13 @@ const AssetEdit = {
591597 map . forEach ( ( { key, input, defaultValue } ) => {
592598 if ( input ) {
593599 input . value = ( data && data [ key ] !== undefined ) ? data [ key ] : defaultValue ;
600+ input . dispatchEvent ( new Event ( 'change' ) ) ;
594601
595602 // Special handling for color input to initialize color picker
596603 if ( key === 'color' && input . value ) {
597604 jQuery ( this . textOverlayColorInput ) . iris ( { color : input . value } ) ;
598605 }
606+
599607 if ( key === 'imageId' && input . value ) {
600608 this . fetchImageById ( input . value ) . then ( attachment => {
601609 AssetEdit . renderImageOverlay ( attachment ) ;
0 commit comments