Skip to content

Commit

Permalink
Expose native image-type asset dimensions on bid response object (#1919)
Browse files Browse the repository at this point in the history
* Pass native image-type dimensions

* Expose native image-type asset dimensions on bid response object
  • Loading branch information
matthewlane authored and jaiminpanchal27 committed Dec 6, 2017
1 parent 6194990 commit 67879a9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
12 changes: 10 additions & 2 deletions modules/appnexusAstBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,16 @@ function newBid(serverBid, rtbBid) {
body: nativeAd.desc,
cta: nativeAd.ctatext,
sponsoredBy: nativeAd.sponsored,
image: nativeAd.main_img && nativeAd.main_img.url,
icon: nativeAd.icon && nativeAd.icon.url,
image: {
url: nativeAd.main_img && nativeAd.main_img.url,
height: nativeAd.main_img && nativeAd.main_img.height,
width: nativeAd.main_img && nativeAd.main_img.width,
},
icon: {
url: nativeAd.icon && nativeAd.icon.url,
height: nativeAd.icon && nativeAd.icon.height,
width: nativeAd.icon && nativeAd.icon.width,
},
clickUrl: nativeAd.link.url,
clickTrackers: nativeAd.link.click_trackers,
impressionTrackers: nativeAd.impression_trackers,
Expand Down
8 changes: 7 additions & 1 deletion src/native.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,13 @@ export function getNativeTargeting(bid) {

Object.keys(bid['native']).forEach(asset => {
const key = NATIVE_KEYS[asset];
const value = bid['native'][asset];
let value = bid['native'][asset];

// native image-type assets can be a string or an object with a url prop
if (typeof value === 'object' && value.url) {
value = value.url;
}

if (key) {
keyValues[key] = value;
}
Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/appnexusAstBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ describe('AppNexusAdapter', () => {
expect(result[0].native.title).to.equal('Native Creative');
expect(result[0].native.body).to.equal('Cool description great stuff');
expect(result[0].native.cta).to.equal('Do it');
expect(result[0].native.image).to.equal('http://cdn.adnxs.com/img.png');
expect(result[0].native.image.url).to.equal('http://cdn.adnxs.com/img.png');
});
});
});

0 comments on commit 67879a9

Please sign in to comment.