From a441a81e92cb1a0dc04498725bf1eb11ed17e499 Mon Sep 17 00:00:00 2001 From: Rich Snapp Date: Fri, 27 Jul 2018 09:54:34 -0600 Subject: [PATCH] make sure size mapping is applied to mediaTypes.banner.sizes as well (#2882) --- src/adaptermanager.js | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/adaptermanager.js b/src/adaptermanager.js index 3d76176d6e2..24c3db6f949 100644 --- a/src/adaptermanager.js +++ b/src/adaptermanager.js @@ -47,21 +47,16 @@ function getLabels(bidOrAdUnit, activeLabels) { function getBids({bidderCode, auctionId, bidderRequestId, adUnits, labels}) { return adUnits.reduce((result, adUnit) => { - let {active, sizes: filteredAdUnitSizes} = resolveStatus(getLabels(adUnit, labels), adUnit.sizes); + let bannerSizes = utils.deepAccess(adUnit, 'mediaTypes.banner.sizes'); + + let {active, sizes: filteredAdUnitSizes} = resolveStatus( + getLabels(adUnit, labels), + bannerSizes || adUnit.sizes + ); if (active) { result.push(adUnit.bids.filter(bid => bid.bidder === bidderCode) .reduce((bids, bid) => { - if (adUnit.mediaTypes) { - if (utils.isValidMediaTypes(adUnit.mediaTypes)) { - bid = Object.assign({}, bid, {mediaTypes: adUnit.mediaTypes}); - } else { - utils.logError( - `mediaTypes is not correctly configured for adunit ${adUnit.code}` - ); - } - } - const nativeParams = adUnit.nativeParams || utils.deepAccess(adUnit, 'mediaTypes.native'); if (nativeParams) { @@ -77,6 +72,22 @@ function getBids({bidderCode, auctionId, bidderRequestId, adUnits, labels}) { let {active, sizes} = resolveStatus(getLabels(bid, labels), filteredAdUnitSizes); + if (adUnit.mediaTypes) { + if (utils.isValidMediaTypes(adUnit.mediaTypes)) { + if (bannerSizes) { + adUnit.mediaTypes.banner.sizes = sizes; + } + + bid = Object.assign({}, bid, { + mediaTypes: adUnit.mediaTypes + }); + } else { + utils.logError( + `mediaTypes is not correctly configured for adunit ${adUnit.code}` + ); + } + } + if (active) { bids.push(Object.assign({}, bid, { adUnitCode: adUnit.code,