Prebid.js icon indicating copy to clipboard operation
Prebid.js copied to clipboard

Native: image min-width/min-height attributes

Open coreyb-cbs opened this issue 5 years ago • 10 comments

Description

Provide the ability to include min_width and min_height on the image asset without requiring ratio_width and ratio_height. OpenRTB native spec differs from Prebid native spec in regards to min-width and min-height attributes for image assets. ORTB includes image.wmin and image.hmin. Prebid has attributes that represent the same thing, but they're nested inside the aspect_ratios attribute and aspect_ratios.ratio_width and aspect_ratios.ratio_height are required if the aspect_ratios option is included. Both publishers and bidders would like to have the ability to include min-width and min-height attributes on image assets without being forced to include an aspect ratio. Including an aspect ratio reduces the potential bid pool. GAM native styles, especially of Fluid size, can responsively handle images of various dimensions and aspect ratios.

OpenRTB spec (image asset is on page 15): https://www.iab.com/wp-content/uploads/2018/03/OpenRTB-Native-Ads-Specification-Final-1.2.pdf

Proposal

The image asset could look like any of the following (all attrs optional):

image: {
     required: true,
     sizes: [300, 200]
}
image: {
     required: true,
     min_sizes: [300, 200]
}
image: {
     required: true,
     min_sizes: [300, 200],
     aspect_ratios: [3, 2]
}

Note

The same could be applied to the icon asset.

coreyb-cbs avatar Apr 26 '21 16:04 coreyb-cbs

Or a simpler alternate proposal which doesn't require an attribute re-factor is to allow the use of aspect_ratios.min_width and aspect_ratios.min_height without requiring aspect_ratios.ratio_width and aspect_ratios.ratio_height. It doesn't feel proper that they're still nested inside aspect_ratios, but it's a less-disruptive modification.

edit: Was testing the case to include aspect_ratios.min_width and aspect_ratios.min_height and not include aspect_ratios.ratio_width and aspect_ratios.ratio_height and it seems the only drawback is that asset.ext is sent as [undefined,undefined]. Ideally asset.ext wouldn't have a value if aspect_ratios.ratio_width and aspect_ratios.ratio_height were not included in the params.

So updating the following line: https://github.com/prebid/Prebid.js/blob/master/modules/prebidServerBidAdapter/index.js#L521

to this: if (params.aspect_ratios.ratio_width && params.aspect_ratios.ratio_height) {

And therefore update the error message in this line: https://github.com/prebid/Prebid.js/blob/master/modules/prebidServerBidAdapter/index.js#L519

to this: throw 'invalid img sizes (must provide sizes or min_height & min_width)';

coreyb-cbs avatar Apr 28 '21 15:04 coreyb-cbs

@coreyb-cbs is this still an issue? I know we made a few different native image prs in recent releases and think one solved this.

ChrisHuie avatar Aug 02 '21 13:08 ChrisHuie

@ChrisHuie I'll review the current Prebid S2S adapter to see if my original concerns have been resolved. Thanks!

coreyb-cbs avatar Aug 03 '21 17:08 coreyb-cbs

@ChrisHuie My comment from April 28 is still relevant:

Was testing the case to include aspect_ratios.min_width and aspect_ratios.min_height and not include aspect_ratios.ratio_width and aspect_ratios.ratio_height and it seems the only drawback is that asset.ext is sent as [undefined,undefined]. Ideally asset.ext wouldn't have a value if aspect_ratios.ratio_width and aspect_ratios.ratio_height were not included in the params.

This conditional should be more specific since it's possible to include aspect_ratios.min_width and aspect_ratios.min_height without including aspect_ratios.ratio_width and aspect_ratios.ratio_height and the subsequent code only deals with ratio_width and ratio_height when setting the ext object.

So at the moment it's: if (Array.isArray(params.aspect_ratios)) { and I believe it should be: if (params.aspect_ratios.ratio_width && params.aspect_ratios.ratio_height) {

We are including min_width and min_height in our requests but we are not including ratio_width and ratio_height so the ext object gets set with undefined values.

coreyb-cbs avatar Aug 16 '21 15:08 coreyb-cbs

@ChrisHuie please reopen ^^^^^

coreyb-cbs avatar Aug 19 '21 16:08 coreyb-cbs

@coreyb-cbs - no one's picked this up because we don't have someone who understands native well enough to see the impacts here end-to-end. So maybe you can help us define what needs to change specifically with respect to the pbsBidAdapter and how PBS needs to accept it? I personally want to avoid constantly tuning PBJS-specific native stuff when it should just be ORTB2.

Also it needs to be noted that PBS is a stickler about proper ORTB2.5. But it doesn't know anything about the Native extensions. If an incoming request doesn't conform, it will be rejected.

Question: What does the native ORTB actually look like? The examples in the native 1.2 doc are partial. My best guess from the docs and from https://github.com/prebid/Prebid.js/blob/c9823f68b26e10f18609177237efab251768046b/modules/prebidServerBidAdapter/index.js#L639 is that imp.native.request is supposed to be a string that contains a JSON object. With quotes escaped. Like this:

imp.native.request: "{\"ver\":\"1.2\", \"context\":2, \"contextsubtype\":20, \"plcmttype\":11, \"plcmtcnt\":1, \"aurlsupport\":0, \"assets\": {...}, ... }"

If this is correct, I would throw out a fairly dramatic suggestion: how about we begin to sidestep the non-ORTB2 history of PBJS and just throw this right in the mediaTypes.native object. e.g.

pbjs.addAdUnits({
    code: slot.code,
    mediaTypes: {
        native: {
            ortb2: STRING-ENCODED-ORTB2NATIVE-FIELD
        }
     }
});

Or if that's too unfriendly, perhaps

pbjs.addAdUnits({
    code: slot.code,
    mediaTypes: {
        native: {
            ortb2: {
               ver: 1.2,
               ... ETC ... nicely formatted Native ORTB1.2 fields defined right in the AdUnit ...
            }
        }
     }
});

On the plus side, native bid adapters (and the pbsBidAdapter) simply need to copy mediaTypes.native.ortb2 into imp.native.request. Then I never again have to think about native and Prebid's annoying non-standard implementation. Life is good.

But there's probably something I'm missing here. Like on the rendering side. It's been so long I've forgotten the details of how the native templates pass data from the bid responses to the in-page renderer. Still, I suspect that's something we can figure out -- like, have the code first check AdUnit.mediaTypes.native.ASSETNAME and if that doesn't exist, check AdUnit.mediaTypes.native.ortb2.assets.ASSETNAME ?

bretg avatar Nov 16 '21 22:11 bretg

@bretg I believe the issue is translating PBJS AdUnits that define a native image or icon media type into ORTB2 Image objects. Even if they could be passed directly as ortb2 objects, it's probably not right to ignore the adunit definition.

To me it looks like they don't match that well: PBJS native images can have multiple sizes and/or aspect ratios (at least according to the public documentation), while ORTB2 Image has only one size and optional min_height/min_width (which in PBJS land are part of the aspect ratio). The current prebid server adapter will expect there to be only one size defined, and will ignore all aspect ratios except the first.

In practice you can make it work as described in the OP but there's some cruft that gets passed along in ext. That is easy to fix but I'm not sure that the conversion as a whole makes sense, or that we should continue to indicate ratio_height and ratio_width as required in https://docs.prebid.org/dev-docs/adunit-reference.html#adunitmediatypesnativeimageaspect_ratios if we are supporting this use case.

dgirardi avatar Nov 16 '21 22:11 dgirardi

Even if they could be passed directly as ortb2 objects, it's probably not right to ignore the adunit definition.

I'm proposing that we add another "advanced" way of defining the adunit. One that's not proprietary. Publishers that want to use ORTB Native features not supported by Prebid's proprietary interface can instead choose to use the ortb2 version.

The benefit is that we stop digging ourselves a proprietary hole.

The drawbacks are:

  • bid adapters would need to change. But I think they'd need to change to support some proprietary new thing anyhow.
  • we probably need to tweak the render logic

bretg avatar Nov 19 '21 21:11 bretg

Closing with merge of #7722

ChrisHuie avatar Dec 02 '21 18:12 ChrisHuie

Thanks @dgirardi and @ChrisHuie !

coreyb-cbs avatar Dec 02 '21 18:12 coreyb-cbs