Skip to content

Commit

Permalink
Show mediaTypes.native.image.sizes in examples
Browse files Browse the repository at this point in the history
In addition to updating the basic examples to use sizes for images and
icons, we add a section to both the API reference and the 'Show Native
Ads' page that lists both ways to define sizes for image-like assets.

Since the content is the same, it's in a shared file sourced using the
Liquid `include` keyword.
  • Loading branch information
Rich Loveland committed Jan 17, 2018
1 parent 9c977b1 commit 635016e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 21 deletions.
31 changes: 31 additions & 0 deletions _includes/dev-docs/native-image-asset-sizes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
There are two methods for defining sizes for image-like assets (`image` and `icon`). Both are shown below, but the first example (using `sizes`) is more widely supported by demand partners.

1. Using `mediaTypes.native.image.sizes` (or `mediaTypes.native.icon.sizes` for icons):

```javascript
mediaTypes: {
native: {
image: {
required: true,
sizes: [150, 50]
}
}
}
```

2. Using `mediaTypes.native.image.aspect_ratios` (or `mediaTypes.native.icon.aspect_ratios` for icons):

```javascript
mediaTypes: {
native: {
image: {
required: true,
aspect_ratios: [{
min_width: 300, /* Optional */
ratio_width: 2, /* Required */
ratio_height: 3, /* Required */
}]
}
}
}
```
15 changes: 5 additions & 10 deletions dev-docs/publisher-api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -620,15 +620,7 @@ For an example of a native ad unit, see below. For more detailed instructions,
native: {
image: {
required: true,

/* If your bidder supports it, you can specify
aspect ratios for image and icon native assets */

aspect_ratios: [{
min_width: 300, /* Optional */
ratio_width: 2, /* Required */
ratio_height: 3, /* Required */
}]
sizes: [150, 50]
},
title: {
required: true,
Expand All @@ -644,7 +636,8 @@ For an example of a native ad unit, see below. For more detailed instructions,
required: true
},
icon: {
required: true
required: true,
sizes: [50, 50]
},
},
bids: [{
Expand All @@ -657,6 +650,8 @@ For an example of a native ad unit, see below. For more detailed instructions,
})
```

{% include dev-docs/native-image-asset-sizes.md %}

<a name="adUnit-video">

##### Video
Expand Down
18 changes: 7 additions & 11 deletions dev-docs/show-native-ads.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ pbjs.addAdUnits({
mediaTypes: {
native: {
image: {
required: true
required: true,
sizes: [150, 50]
},
title: {
required: true,
Expand All @@ -130,7 +131,8 @@ pbjs.addAdUnits({
required: true
},
icon: {
required: true
required: true,
sizes: [50, 50]
},
},
bids: [{
Expand Down Expand Up @@ -175,15 +177,7 @@ A native "image-type" ad unit can be set up as shown in the following example.
native: {
image: {
required: true,

/* If your bidder supports it, you can specify aspect
ratios for image and icon native assets */

aspect_ratios: [{
min_width: 300, /* Optional */
ratio_width: 2, /* Required */
ratio_height: 3, /* Required */
}]
sizes: [150, 50]
}
}
}
Expand All @@ -196,6 +190,8 @@ A native "image-type" ad unit can be set up as shown in the following example.
}];
```

{% include dev-docs/native-image-asset-sizes.md %}

### 3. Add your native ad tag to the page body as usual:

{% highlight html %}
Expand Down

0 comments on commit 635016e

Please sign in to comment.