amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

When amp-ad is configured with layout=responsive, always center ad in iframe

Open jasti opened this issue 10 years ago • 10 comments

When publishers use layout=responsive for amp-ad and the response is a fixed pixel creative, the creative ends up being left and top aligned. It should be vertically and horizontally centered regardless of the response.

You can see this in: screen shot 2016-08-24 at 4 47 06 pm

Live article : http://www.theatlantic.com/amp/article/497159/ Code snippet : http://output.jsbin.com/fehayafoso

What browsers are affected?

I tested this in Safari on an iphone 6.

Which AMP version is affected?

It was always this way.

jasti avatar Aug 24 '16 20:08 jasti

@lannka thoughts?

jasti avatar Aug 24 '16 22:08 jasti

FWIW, this is what we do for embeds such as Twitter, so I don't see why we should not do it for ads as well.

dvoytenko avatar Aug 25 '16 11:08 dvoytenko

I agree with @jasti that in this case center align will be a better UI treatment.

However, after taking a look at the creative, I noticed it's really out of AMP's control. The creative is in a nested iframe, and it should be the creative CSS to center align it.

Seems it's a doubleclick ad, do we let publisher configure alignment in DFP?

lannka avatar Aug 25 '16 17:08 lannka

No, not really. @mlb7687 for thoughts. Sounds like something that was served using GPT Light.

jasti avatar Aug 26 '16 02:08 jasti

Looks like you get the same layout with both GPT and GPT Light. Seems like something that is fixable though. Since multi-size is not currently supported, we are still issuing the ad request with the defined size. So if we explicitly define the ad iframe size, we should be able to do the centering in doubleclick.js. Let me play around with it and see what I can come up with.

mlb7687 avatar Aug 26 '16 12:08 mlb7687

Should we close this issue?

jridgewell avatar Aug 26 '16 18:08 jridgewell

@jridgewell It sounds like we'll fix this along with https://github.com/ampproject/amphtml/issues/3176 which we are actively working on. @mlb7687 is looking into it. So, if okay, would like to keep it open.

jasti avatar Aug 26 '16 18:08 jasti

@jasti, this bug and #3176 are distinct issues fwiw. Getting around to looking at this closer now, but I'd expect a fix for this much sooner that multisize changes being in place.

mlb7687 avatar Aug 26 '16 19:08 mlb7687

PR for fix: https://github.com/ampproject/amphtml/pull/4735 If there are any objections to this approach, please let me know, happy to consider others. Had to pass layout information into 3p frame somehow, so chose to add it onto window.context.

mlb7687 avatar Aug 26 '16 21:08 mlb7687

try to add the below in css. amp-ad{ direction: initial; }

omeryounus avatar Jan 03 '18 08:01 omeryounus