amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Conditionally load component based on size of another

Open bjalford opened this issue 9 years ago • 9 comments

Got an odd one to try and work out how to do in AMP.

Let's say there is a container in a grid that is 600 pixels high. The current 'web' behaviour I'm trying to match is:

An ad is loaded in the container. If the ad is is 600 pixels tall then nothing else happens as the area is filled.

If the ad is 300 pixels high then an additional call is made to bring in a second 300 pixels ad so that the container is full.

You can see the current implementation in the right of the top row on desktop here: http://www.independent.co.uk

bjalford avatar Feb 08 '17 18:02 bjalford

/to @camelburrito /cc @ericlindley-g

dvoytenko avatar Feb 10 '17 02:02 dvoytenko

Is there a non-ads use case for this?

/cc @jasti

ericlindley-g avatar Feb 10 '17 16:02 ericlindley-g

Could this be solved by <amp-auto-ads>?

jridgewell avatar Feb 11 '17 05:02 jridgewell

@tlong2 for if this relates to <amp-auto-ads>. @bjalford this is indeed an odd one. Do you plan to see this sort of thing happen in mobile? I don't know of any other publisher doing this/ wanting this, so will be low priority for the core team. Please feel free to send a PR though.

jasti avatar Feb 21 '17 14:02 jasti

I don't think <amp-auto-ads> will be particularly useful for this. Doesn't sound like what's being suggested here would ever need to resize the container. It would just need to shrink the first <amp-ad> to the size of it's contents and then insert a second <amp-ad> in the remaining space.

tlong2 avatar Feb 21 '17 17:02 tlong2

Doesn't sound like what's being suggested here would ever need to resize the container. It would just need to shrink the first to the size of it's contents and then insert a second in the remaining space.

That's exactly what I mean. A call is made using <amp-auto-ads>, it decides it can fit 2 300px ads into this 600px container, it returns both ads.

jridgewell avatar Feb 21 '17 19:02 jridgewell

I guess it depends what is making the choice about how big the ad is. I assumed that @bjalford was talking about having a 600px that makes a 600px-height request to the ad server. If the ad server choses to only fill it with a 300px ad, then something client side creates a second 300px ad to fill the space.

If my interpretation above is correct, then the sizing decision is not something <amp-auto-ads> could help with since all it's logic runs before any kind of ad request is made.

tlong2 avatar Feb 21 '17 21:02 tlong2

Thanks - just a note to say I'll reply beginning of next week

bjalford avatar Feb 24 '17 13:02 bjalford

Ping @bjalford

jasti avatar Mar 24 '17 18:03 jasti