Add API to amp-ad to expose parent viewport size?
I've possibly overlooked this, but is there a way to expose the width of the article that the amp-ad is located in? If not, could you add a method to window.context that could return the width of the parent article?
We are trying to run ads that maintain their aspect ratio and they want to be 100% width of their parent element. After #2263 is merged we'll have a working resize :tada:! And the last thing we'd need to get our custom ads fully supported would be this functionality.
You can just make the ad layout="responsive" which gets you the sizing you need (also check out the heights attribute). Then inside the iframe you can just measure its size and you should be good. We could pass it down, but you also have to handle the case of resizing (e.g. on device rotation).
+1 to using layout="responsive"
This fixed it! :tada: thanks @sriramkrish85 and @cramforce