diff --git a/modules/yieldlabBidAdapter.js b/modules/yieldlabBidAdapter.js index 682eca6be0dc..31e9b35f1782 100644 --- a/modules/yieldlabBidAdapter.js +++ b/modules/yieldlabBidAdapter.js @@ -186,7 +186,7 @@ export const spec = { // there may be publishers still rely on it bidResponse.adUrl = `${ENDPOINT}/d/${matchedBid.id}/${bidRequest.params.supplyId}/?ts=${timestamp}${extId}${gdprApplies}${gdprConsent}${pvId}`; bidResponse.mediaType = NATIVE; - const nativeImageAssetObj = find(matchedBid.native.assets, asset => hasValidProperty(asset, 'img')); + const nativeImageAssetObj = find(matchedBid.native.assets, asset => isMainImage(asset)); const nativeImageAsset = nativeImageAssetObj ? nativeImageAssetObj.img : { url: '', w: 0, h: 0 }; const nativeTitleAsset = find(matchedBid.native.assets, asset => hasValidProperty(asset, 'title')); const nativeBodyAsset = find(matchedBid.native.assets, asset => hasValidProperty(asset, 'data')); @@ -516,4 +516,15 @@ function hasValidProperty(obj, propName) { return obj.hasOwnProperty(propName) && obj[propName] != null; } +/** + * Checks if an asset object is a main image. + * A main image is defined as an image asset whose type value is 3. + * + * @param {Object} asset - The asset object to check. + * @returns {boolean} Returns true if the object has a property img.type with a value of 3, otherwise false. + */ +function isMainImage(asset) { + return asset?.img?.type === 3 +} + registerBidder(spec); diff --git a/test/spec/modules/yieldlabBidAdapter_spec.js b/test/spec/modules/yieldlabBidAdapter_spec.js index 57f13468c0ff..76c4aca4f42c 100644 --- a/test/spec/modules/yieldlabBidAdapter_spec.js +++ b/test/spec/modules/yieldlabBidAdapter_spec.js @@ -191,6 +191,7 @@ const NATIVE_RESPONSE = Object.assign({}, RESPONSE, { url: 'https://localhost:8080/yl-logo100x100.jpg', w: 100, h: 100, + type: 3, }, }, { @@ -557,7 +558,6 @@ describe('yieldlabBidAdapter', () => { it('should add adUrl and native assets when type is Native', () => { const result = spec.interpretResponse({body: [NATIVE_RESPONSE]}, {validBidRequests: [NATIVE_REQUEST()], queryParams: REQPARAMS}); - expect(result[0].requestId).to.equal('2d925f27f5079f'); expect(result[0].cpm).to.equal(0.01); expect(result[0].mediaType).to.equal('native');