@adstage/web-sdk 2.2.1 โ 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +43 -16
- package/dist/index.esm.js +43 -16
- package/dist/index.standalone.js +43 -16
- package/package.json +2 -2
- package/src/modules/ads/AdsModule.ts +35 -10
- package/src/renderers/base-renderer.ts +10 -6
package/dist/index.cjs.js
CHANGED
|
@@ -392,18 +392,23 @@ class BaseAdRenderer {
|
|
|
392
392
|
getImageStyles(slot) {
|
|
393
393
|
const styles = {
|
|
394
394
|
display: 'block',
|
|
395
|
-
'max-width': '100%',
|
|
396
|
-
height: 'auto',
|
|
397
395
|
'object-position': 'center', // ๐ฏ ์ด๋ฏธ์ง ํญ์ ์ค์ ์ ๋ ฌ
|
|
398
396
|
};
|
|
399
|
-
// ์ฌ์ฉ์๊ฐ ์ปจํ
์ด๋ ํฌ๊ธฐ๋ฅผ
|
|
397
|
+
// ์ฌ์ฉ์๊ฐ ์ปจํ
์ด๋ ํฌ๊ธฐ๋ฅผ ์ง์ ํ๋์ง ํ์ธ
|
|
400
398
|
const parsedWidth = this.parseSizeValue(slot?.width);
|
|
401
399
|
const parsedHeight = this.parseSizeValue(slot?.height);
|
|
402
|
-
|
|
400
|
+
const hasUserDefinedSize = parsedWidth || parsedHeight;
|
|
401
|
+
if (hasUserDefinedSize) {
|
|
402
|
+
// ๐ฏ ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ: ์ปจํ
์ด๋์ ๊ฝ ์ฐจ๋๋ก ์ค์
|
|
403
403
|
styles.width = '100%';
|
|
404
404
|
styles.height = '100%';
|
|
405
|
-
styles['object-fit'] = 'cover';
|
|
406
|
-
styles['object-position'] = 'center';
|
|
405
|
+
styles['object-fit'] = 'cover'; // ์ปจํ
์ด๋์ ๊ฝ ์ฐฌ ์ํ๋ก ๋น์จ ์ ์ง
|
|
406
|
+
styles['object-position'] = 'center';
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ: ์๋ณธ ์ด๋ฏธ์ง ํฌ๊ธฐ ์ ์ง
|
|
410
|
+
styles['max-width'] = '100%';
|
|
411
|
+
styles.height = 'auto';
|
|
407
412
|
}
|
|
408
413
|
return styles;
|
|
409
414
|
}
|
|
@@ -2886,23 +2891,45 @@ class AdsModule {
|
|
|
2886
2891
|
*/
|
|
2887
2892
|
async renderOptimizedBannerImage(adElement, ad, slot) {
|
|
2888
2893
|
try {
|
|
2889
|
-
//
|
|
2890
|
-
const
|
|
2891
|
-
const
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ๋์ง ํ์ธ
|
|
2895
|
+
const configWidth = slot.config?.width;
|
|
2896
|
+
const configHeight = slot.config?.height;
|
|
2897
|
+
const hasUserDefinedWidth = configWidth &&
|
|
2898
|
+
(typeof configWidth === 'number' || (typeof configWidth === 'string' && configWidth !== '100%'));
|
|
2899
|
+
const hasUserDefinedHeight = configHeight &&
|
|
2900
|
+
(typeof configHeight === 'number' || (typeof configHeight === 'string' && configHeight !== 'auto'));
|
|
2901
|
+
const hasUserDefinedSize = hasUserDefinedWidth || hasUserDefinedHeight;
|
|
2894
2902
|
// ์ด๋ฏธ์ง ์์ ์์ฑ
|
|
2895
2903
|
const img = document.createElement('img');
|
|
2896
2904
|
img.src = ad.imageUrl;
|
|
2897
2905
|
img.alt = ad.title;
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2906
|
+
if (hasUserDefinedSize) {
|
|
2907
|
+
// ๐ฏ ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ: ์ปจํ
์ด๋์ ๊ฝ ์ฐจ๋๋ก ์ค์
|
|
2908
|
+
img.style.width = '100%';
|
|
2909
|
+
img.style.height = '100%';
|
|
2910
|
+
img.style.objectFit = 'cover'; // ์ปจํ
์ด๋์ ๊ฝ ์ฐฌ ์ํ๋ก ๋น์จ ์ ์ง
|
|
2911
|
+
img.style.objectPosition = 'center';
|
|
2912
|
+
if (this._config?.debug) {
|
|
2913
|
+
console.log(`๐ฏ User-defined size detected: filling container completely`);
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
else {
|
|
2917
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ: ๋์ ์ต์ ํ ์ ์ฉ
|
|
2918
|
+
const imageDimensions = await this.loadImageDimensions(ad.imageUrl);
|
|
2919
|
+
const imageAspectRatio = imageDimensions.width / imageDimensions.height;
|
|
2920
|
+
const containerAspectRatio = slot.aspectRatio || 16 / 9;
|
|
2921
|
+
img.style.width = '100%';
|
|
2922
|
+
img.style.height = '100%';
|
|
2923
|
+
// ๐จ ์ต์ ํ๋ ์คํ์ผ ์ ์ฉ
|
|
2924
|
+
this.applyOptimizedImageStyle(img, imageAspectRatio, containerAspectRatio);
|
|
2925
|
+
if (this._config?.debug) {
|
|
2926
|
+
console.log(`๐ผ๏ธ Optimized banner image loaded: ${imageDimensions.width}x${imageDimensions.height} (ratio: ${imageAspectRatio.toFixed(2)})`);
|
|
2927
|
+
}
|
|
2928
|
+
}
|
|
2902
2929
|
// ์ด๋ฏธ์ง ๋ก๋ ์๋ฃ ์ฒ๋ฆฌ
|
|
2903
2930
|
img.onload = () => {
|
|
2904
2931
|
if (this._config?.debug) {
|
|
2905
|
-
console.log(
|
|
2932
|
+
console.log(`โ
Banner image loaded successfully`);
|
|
2906
2933
|
}
|
|
2907
2934
|
};
|
|
2908
2935
|
// ์๋ฌ ์ฒ๋ฆฌ
|
package/dist/index.esm.js
CHANGED
|
@@ -390,18 +390,23 @@ class BaseAdRenderer {
|
|
|
390
390
|
getImageStyles(slot) {
|
|
391
391
|
const styles = {
|
|
392
392
|
display: 'block',
|
|
393
|
-
'max-width': '100%',
|
|
394
|
-
height: 'auto',
|
|
395
393
|
'object-position': 'center', // ๐ฏ ์ด๋ฏธ์ง ํญ์ ์ค์ ์ ๋ ฌ
|
|
396
394
|
};
|
|
397
|
-
// ์ฌ์ฉ์๊ฐ ์ปจํ
์ด๋ ํฌ๊ธฐ๋ฅผ
|
|
395
|
+
// ์ฌ์ฉ์๊ฐ ์ปจํ
์ด๋ ํฌ๊ธฐ๋ฅผ ์ง์ ํ๋์ง ํ์ธ
|
|
398
396
|
const parsedWidth = this.parseSizeValue(slot?.width);
|
|
399
397
|
const parsedHeight = this.parseSizeValue(slot?.height);
|
|
400
|
-
|
|
398
|
+
const hasUserDefinedSize = parsedWidth || parsedHeight;
|
|
399
|
+
if (hasUserDefinedSize) {
|
|
400
|
+
// ๐ฏ ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ: ์ปจํ
์ด๋์ ๊ฝ ์ฐจ๋๋ก ์ค์
|
|
401
401
|
styles.width = '100%';
|
|
402
402
|
styles.height = '100%';
|
|
403
|
-
styles['object-fit'] = 'cover';
|
|
404
|
-
styles['object-position'] = 'center';
|
|
403
|
+
styles['object-fit'] = 'cover'; // ์ปจํ
์ด๋์ ๊ฝ ์ฐฌ ์ํ๋ก ๋น์จ ์ ์ง
|
|
404
|
+
styles['object-position'] = 'center';
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ: ์๋ณธ ์ด๋ฏธ์ง ํฌ๊ธฐ ์ ์ง
|
|
408
|
+
styles['max-width'] = '100%';
|
|
409
|
+
styles.height = 'auto';
|
|
405
410
|
}
|
|
406
411
|
return styles;
|
|
407
412
|
}
|
|
@@ -2884,23 +2889,45 @@ class AdsModule {
|
|
|
2884
2889
|
*/
|
|
2885
2890
|
async renderOptimizedBannerImage(adElement, ad, slot) {
|
|
2886
2891
|
try {
|
|
2887
|
-
//
|
|
2888
|
-
const
|
|
2889
|
-
const
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ๋์ง ํ์ธ
|
|
2893
|
+
const configWidth = slot.config?.width;
|
|
2894
|
+
const configHeight = slot.config?.height;
|
|
2895
|
+
const hasUserDefinedWidth = configWidth &&
|
|
2896
|
+
(typeof configWidth === 'number' || (typeof configWidth === 'string' && configWidth !== '100%'));
|
|
2897
|
+
const hasUserDefinedHeight = configHeight &&
|
|
2898
|
+
(typeof configHeight === 'number' || (typeof configHeight === 'string' && configHeight !== 'auto'));
|
|
2899
|
+
const hasUserDefinedSize = hasUserDefinedWidth || hasUserDefinedHeight;
|
|
2892
2900
|
// ์ด๋ฏธ์ง ์์ ์์ฑ
|
|
2893
2901
|
const img = document.createElement('img');
|
|
2894
2902
|
img.src = ad.imageUrl;
|
|
2895
2903
|
img.alt = ad.title;
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2904
|
+
if (hasUserDefinedSize) {
|
|
2905
|
+
// ๐ฏ ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ: ์ปจํ
์ด๋์ ๊ฝ ์ฐจ๋๋ก ์ค์
|
|
2906
|
+
img.style.width = '100%';
|
|
2907
|
+
img.style.height = '100%';
|
|
2908
|
+
img.style.objectFit = 'cover'; // ์ปจํ
์ด๋์ ๊ฝ ์ฐฌ ์ํ๋ก ๋น์จ ์ ์ง
|
|
2909
|
+
img.style.objectPosition = 'center';
|
|
2910
|
+
if (this._config?.debug) {
|
|
2911
|
+
console.log(`๐ฏ User-defined size detected: filling container completely`);
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
else {
|
|
2915
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ: ๋์ ์ต์ ํ ์ ์ฉ
|
|
2916
|
+
const imageDimensions = await this.loadImageDimensions(ad.imageUrl);
|
|
2917
|
+
const imageAspectRatio = imageDimensions.width / imageDimensions.height;
|
|
2918
|
+
const containerAspectRatio = slot.aspectRatio || 16 / 9;
|
|
2919
|
+
img.style.width = '100%';
|
|
2920
|
+
img.style.height = '100%';
|
|
2921
|
+
// ๐จ ์ต์ ํ๋ ์คํ์ผ ์ ์ฉ
|
|
2922
|
+
this.applyOptimizedImageStyle(img, imageAspectRatio, containerAspectRatio);
|
|
2923
|
+
if (this._config?.debug) {
|
|
2924
|
+
console.log(`๐ผ๏ธ Optimized banner image loaded: ${imageDimensions.width}x${imageDimensions.height} (ratio: ${imageAspectRatio.toFixed(2)})`);
|
|
2925
|
+
}
|
|
2926
|
+
}
|
|
2900
2927
|
// ์ด๋ฏธ์ง ๋ก๋ ์๋ฃ ์ฒ๋ฆฌ
|
|
2901
2928
|
img.onload = () => {
|
|
2902
2929
|
if (this._config?.debug) {
|
|
2903
|
-
console.log(
|
|
2930
|
+
console.log(`โ
Banner image loaded successfully`);
|
|
2904
2931
|
}
|
|
2905
2932
|
};
|
|
2906
2933
|
// ์๋ฌ ์ฒ๋ฆฌ
|
package/dist/index.standalone.js
CHANGED
|
@@ -390,18 +390,23 @@ class BaseAdRenderer {
|
|
|
390
390
|
getImageStyles(slot) {
|
|
391
391
|
const styles = {
|
|
392
392
|
display: 'block',
|
|
393
|
-
'max-width': '100%',
|
|
394
|
-
height: 'auto',
|
|
395
393
|
'object-position': 'center', // ๐ฏ ์ด๋ฏธ์ง ํญ์ ์ค์ ์ ๋ ฌ
|
|
396
394
|
};
|
|
397
|
-
// ์ฌ์ฉ์๊ฐ ์ปจํ
์ด๋ ํฌ๊ธฐ๋ฅผ
|
|
395
|
+
// ์ฌ์ฉ์๊ฐ ์ปจํ
์ด๋ ํฌ๊ธฐ๋ฅผ ์ง์ ํ๋์ง ํ์ธ
|
|
398
396
|
const parsedWidth = this.parseSizeValue(slot?.width);
|
|
399
397
|
const parsedHeight = this.parseSizeValue(slot?.height);
|
|
400
|
-
|
|
398
|
+
const hasUserDefinedSize = parsedWidth || parsedHeight;
|
|
399
|
+
if (hasUserDefinedSize) {
|
|
400
|
+
// ๐ฏ ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ: ์ปจํ
์ด๋์ ๊ฝ ์ฐจ๋๋ก ์ค์
|
|
401
401
|
styles.width = '100%';
|
|
402
402
|
styles.height = '100%';
|
|
403
|
-
styles['object-fit'] = 'cover';
|
|
404
|
-
styles['object-position'] = 'center';
|
|
403
|
+
styles['object-fit'] = 'cover'; // ์ปจํ
์ด๋์ ๊ฝ ์ฐฌ ์ํ๋ก ๋น์จ ์ ์ง
|
|
404
|
+
styles['object-position'] = 'center';
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ: ์๋ณธ ์ด๋ฏธ์ง ํฌ๊ธฐ ์ ์ง
|
|
408
|
+
styles['max-width'] = '100%';
|
|
409
|
+
styles.height = 'auto';
|
|
405
410
|
}
|
|
406
411
|
return styles;
|
|
407
412
|
}
|
|
@@ -2884,23 +2889,45 @@ class AdsModule {
|
|
|
2884
2889
|
*/
|
|
2885
2890
|
async renderOptimizedBannerImage(adElement, ad, slot) {
|
|
2886
2891
|
try {
|
|
2887
|
-
//
|
|
2888
|
-
const
|
|
2889
|
-
const
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ๋์ง ํ์ธ
|
|
2893
|
+
const configWidth = slot.config?.width;
|
|
2894
|
+
const configHeight = slot.config?.height;
|
|
2895
|
+
const hasUserDefinedWidth = configWidth &&
|
|
2896
|
+
(typeof configWidth === 'number' || (typeof configWidth === 'string' && configWidth !== '100%'));
|
|
2897
|
+
const hasUserDefinedHeight = configHeight &&
|
|
2898
|
+
(typeof configHeight === 'number' || (typeof configHeight === 'string' && configHeight !== 'auto'));
|
|
2899
|
+
const hasUserDefinedSize = hasUserDefinedWidth || hasUserDefinedHeight;
|
|
2892
2900
|
// ์ด๋ฏธ์ง ์์ ์์ฑ
|
|
2893
2901
|
const img = document.createElement('img');
|
|
2894
2902
|
img.src = ad.imageUrl;
|
|
2895
2903
|
img.alt = ad.title;
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2904
|
+
if (hasUserDefinedSize) {
|
|
2905
|
+
// ๐ฏ ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ: ์ปจํ
์ด๋์ ๊ฝ ์ฐจ๋๋ก ์ค์
|
|
2906
|
+
img.style.width = '100%';
|
|
2907
|
+
img.style.height = '100%';
|
|
2908
|
+
img.style.objectFit = 'cover'; // ์ปจํ
์ด๋์ ๊ฝ ์ฐฌ ์ํ๋ก ๋น์จ ์ ์ง
|
|
2909
|
+
img.style.objectPosition = 'center';
|
|
2910
|
+
if (this._config?.debug) {
|
|
2911
|
+
console.log(`๐ฏ User-defined size detected: filling container completely`);
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
else {
|
|
2915
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ: ๋์ ์ต์ ํ ์ ์ฉ
|
|
2916
|
+
const imageDimensions = await this.loadImageDimensions(ad.imageUrl);
|
|
2917
|
+
const imageAspectRatio = imageDimensions.width / imageDimensions.height;
|
|
2918
|
+
const containerAspectRatio = slot.aspectRatio || 16 / 9;
|
|
2919
|
+
img.style.width = '100%';
|
|
2920
|
+
img.style.height = '100%';
|
|
2921
|
+
// ๐จ ์ต์ ํ๋ ์คํ์ผ ์ ์ฉ
|
|
2922
|
+
this.applyOptimizedImageStyle(img, imageAspectRatio, containerAspectRatio);
|
|
2923
|
+
if (this._config?.debug) {
|
|
2924
|
+
console.log(`๐ผ๏ธ Optimized banner image loaded: ${imageDimensions.width}x${imageDimensions.height} (ratio: ${imageAspectRatio.toFixed(2)})`);
|
|
2925
|
+
}
|
|
2926
|
+
}
|
|
2900
2927
|
// ์ด๋ฏธ์ง ๋ก๋ ์๋ฃ ์ฒ๋ฆฌ
|
|
2901
2928
|
img.onload = () => {
|
|
2902
2929
|
if (this._config?.debug) {
|
|
2903
|
-
console.log(
|
|
2930
|
+
console.log(`โ
Banner image loaded successfully`);
|
|
2904
2931
|
}
|
|
2905
2932
|
};
|
|
2906
2933
|
// ์๋ฌ ์ฒ๋ฆฌ
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adstage/web-sdk",
|
|
3
|
-
"version": "2.2.
|
|
4
|
-
"description": "AdStage Web SDK - Production-ready marketing platform SDK with auto-initialization, dynamic sizing,
|
|
3
|
+
"version": "2.2.2",
|
|
4
|
+
"description": "AdStage Web SDK - Production-ready marketing platform SDK with auto-initialization, dynamic sizing, centered image positioning, and user-defined size support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
7
7
|
"module": "dist/index.esm.js",
|
|
@@ -1076,27 +1076,52 @@ export class AdsModule implements BaseModule {
|
|
|
1076
1076
|
*/
|
|
1077
1077
|
private async renderOptimizedBannerImage(adElement: HTMLElement, ad: Advertisement, slot: AdSlot): Promise<void> {
|
|
1078
1078
|
try {
|
|
1079
|
-
//
|
|
1080
|
-
const
|
|
1081
|
-
const
|
|
1079
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ๋์ง ํ์ธ
|
|
1080
|
+
const configWidth = slot.config?.width;
|
|
1081
|
+
const configHeight = slot.config?.height;
|
|
1082
1082
|
|
|
1083
|
-
|
|
1084
|
-
|
|
1083
|
+
const hasUserDefinedWidth = configWidth &&
|
|
1084
|
+
(typeof configWidth === 'number' || (typeof configWidth === 'string' && configWidth !== '100%'));
|
|
1085
|
+
const hasUserDefinedHeight = configHeight &&
|
|
1086
|
+
(typeof configHeight === 'number' || (typeof configHeight === 'string' && configHeight !== 'auto'));
|
|
1087
|
+
const hasUserDefinedSize = hasUserDefinedWidth || hasUserDefinedHeight;
|
|
1085
1088
|
|
|
1086
1089
|
// ์ด๋ฏธ์ง ์์ ์์ฑ
|
|
1087
1090
|
const img = document.createElement('img');
|
|
1088
1091
|
img.src = ad.imageUrl!;
|
|
1089
1092
|
img.alt = ad.title;
|
|
1090
|
-
img.style.width = '100%';
|
|
1091
|
-
img.style.height = '100%';
|
|
1092
1093
|
|
|
1093
|
-
|
|
1094
|
-
|
|
1094
|
+
if (hasUserDefinedSize) {
|
|
1095
|
+
// ๐ฏ ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ: ์ปจํ
์ด๋์ ๊ฝ ์ฐจ๋๋ก ์ค์
|
|
1096
|
+
img.style.width = '100%';
|
|
1097
|
+
img.style.height = '100%';
|
|
1098
|
+
img.style.objectFit = 'cover'; // ์ปจํ
์ด๋์ ๊ฝ ์ฐฌ ์ํ๋ก ๋น์จ ์ ์ง
|
|
1099
|
+
img.style.objectPosition = 'center';
|
|
1100
|
+
|
|
1101
|
+
if (this._config?.debug) {
|
|
1102
|
+
console.log(`๐ฏ User-defined size detected: filling container completely`);
|
|
1103
|
+
}
|
|
1104
|
+
} else {
|
|
1105
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ: ๋์ ์ต์ ํ ์ ์ฉ
|
|
1106
|
+
const imageDimensions = await this.loadImageDimensions(ad.imageUrl!);
|
|
1107
|
+
const imageAspectRatio = imageDimensions.width / imageDimensions.height;
|
|
1108
|
+
const containerAspectRatio = (slot as any).aspectRatio || 16/9;
|
|
1109
|
+
|
|
1110
|
+
img.style.width = '100%';
|
|
1111
|
+
img.style.height = '100%';
|
|
1112
|
+
|
|
1113
|
+
// ๐จ ์ต์ ํ๋ ์คํ์ผ ์ ์ฉ
|
|
1114
|
+
this.applyOptimizedImageStyle(img, imageAspectRatio, containerAspectRatio);
|
|
1115
|
+
|
|
1116
|
+
if (this._config?.debug) {
|
|
1117
|
+
console.log(`๐ผ๏ธ Optimized banner image loaded: ${imageDimensions.width}x${imageDimensions.height} (ratio: ${imageAspectRatio.toFixed(2)})`);
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1095
1120
|
|
|
1096
1121
|
// ์ด๋ฏธ์ง ๋ก๋ ์๋ฃ ์ฒ๋ฆฌ
|
|
1097
1122
|
img.onload = () => {
|
|
1098
1123
|
if (this._config?.debug) {
|
|
1099
|
-
console.log(
|
|
1124
|
+
console.log(`โ
Banner image loaded successfully`);
|
|
1100
1125
|
}
|
|
1101
1126
|
};
|
|
1102
1127
|
|
|
@@ -108,20 +108,24 @@ export abstract class BaseAdRenderer implements AdRenderer {
|
|
|
108
108
|
protected getImageStyles(slot?: AdSlot): Record<string, string> {
|
|
109
109
|
const styles: Record<string, string> = {
|
|
110
110
|
display: 'block',
|
|
111
|
-
'max-width': '100%',
|
|
112
|
-
height: 'auto',
|
|
113
111
|
'object-position': 'center', // ๐ฏ ์ด๋ฏธ์ง ํญ์ ์ค์ ์ ๋ ฌ
|
|
114
112
|
};
|
|
115
113
|
|
|
116
|
-
// ์ฌ์ฉ์๊ฐ ์ปจํ
์ด๋ ํฌ๊ธฐ๋ฅผ
|
|
114
|
+
// ์ฌ์ฉ์๊ฐ ์ปจํ
์ด๋ ํฌ๊ธฐ๋ฅผ ์ง์ ํ๋์ง ํ์ธ
|
|
117
115
|
const parsedWidth = this.parseSizeValue(slot?.width);
|
|
118
116
|
const parsedHeight = this.parseSizeValue(slot?.height);
|
|
117
|
+
const hasUserDefinedSize = parsedWidth || parsedHeight;
|
|
119
118
|
|
|
120
|
-
if (
|
|
119
|
+
if (hasUserDefinedSize) {
|
|
120
|
+
// ๐ฏ ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ: ์ปจํ
์ด๋์ ๊ฝ ์ฐจ๋๋ก ์ค์
|
|
121
121
|
styles.width = '100%';
|
|
122
122
|
styles.height = '100%';
|
|
123
|
-
styles['object-fit'] = 'cover';
|
|
124
|
-
styles['object-position'] = 'center';
|
|
123
|
+
styles['object-fit'] = 'cover'; // ์ปจํ
์ด๋์ ๊ฝ ์ฐฌ ์ํ๋ก ๋น์จ ์ ์ง
|
|
124
|
+
styles['object-position'] = 'center';
|
|
125
|
+
} else {
|
|
126
|
+
// ์ฌ์ฉ์๊ฐ ํฌ๊ธฐ๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ: ์๋ณธ ์ด๋ฏธ์ง ํฌ๊ธฐ ์ ์ง
|
|
127
|
+
styles['max-width'] = '100%';
|
|
128
|
+
styles.height = 'auto';
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
return styles;
|