Skip to content

Commit

Permalink
Update renderAd to replace ${AUCTION_PRICE} in adUrl (#1795)
Browse files Browse the repository at this point in the history
* Modify `adUrl` instead of `url` with bid price

The `bid.url` parameter is not used to render the iframe for an ad that
returns a url but is being treated as such when the auction price is
being inserted. This commit inserts the auction price into `bid.adUrl`
which is used to render the ad.

* Use the key for adUrl instead of using url

Instead of renaming the parameter `adUrl` to `url` for the rendering
function, use `adUrl` to be consistent with the key value returned in
the bid object.
  • Loading branch information
klawil authored and matthewlane committed Nov 14, 2017
1 parent bd8d8ba commit 9bd0c46
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,14 @@ $$PREBID_GLOBAL$$.renderAd = function (doc, id) {
if (bid) {
// replace macros according to openRTB with price paid = bid.cpm
bid.ad = utils.replaceAuctionPrice(bid.ad, bid.cpm);
bid.url = utils.replaceAuctionPrice(bid.url, bid.cpm);
bid.adUrl = utils.replaceAuctionPrice(bid.adUrl, bid.cpm);
// save winning bids
$$PREBID_GLOBAL$$._winningBids.push(bid);

// emit 'bid won' event here
events.emit(BID_WON, bid);

const { height, width, ad, mediaType, adUrl: url, renderer } = bid;
const { height, width, ad, mediaType, adUrl, renderer } = bid;

if (renderer && renderer.url) {
renderer.render(bid);
Expand All @@ -299,13 +299,13 @@ $$PREBID_GLOBAL$$.renderAd = function (doc, id) {
doc.write(ad);
doc.close();
setRenderSize(doc, width, height);
} else if (url) {
} else if (adUrl) {
const iframe = utils.createInvisibleIframe();
iframe.height = height;
iframe.width = width;
iframe.style.display = 'inline';
iframe.style.overflow = 'hidden';
iframe.src = url;
iframe.src = adUrl;

utils.insertElement(iframe, doc, 'body');
setRenderSize(doc, width, height);
Expand Down

0 comments on commit 9bd0c46

Please sign in to comment.