Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

amp-img error: Layout not supported for: container

Tags:

amp-html

Trying to validate my amp-img. In this example: http://staging.laineygossip.com/Sasha-Celeb-Finds-Sienna-Miller/Lifestyle/24695/amp#development=1

I get the error: Layout not supported for: container
In the console, the error is: The specified layout 'CONTAINER' is not supported by tag 'amp-img'

Not sure what this error means.

So far I can't find anything in the docs that relates to this error message.

like image 223
Ken Ma Avatar asked Aug 03 '16 06:08

Ken Ma


4 Answers

As per google AMP docs, layouts supported:

FILL, FIXED, FIXED-HEIGHT, FLEX-ITEM, NODISPLAY, RESPONSIVE

Also look at this example, I don't think you need quotes around the layout type: https://ampbyexample.com/samples_templates/news_article/

So it should look something like this:

  <figure>
    <amp-img src="/img/landscape_village_1280x720.jpg"
      width=1280
      height=768
      layout=responsive></amp-img>
   <figcaption>Here is a responsive image.</figcaption>
 </figure>
like image 82
Ksenia Avatar answered Nov 16 '22 06:11

Ksenia


Amp defaults to layout="container" if there is no width and height attribute set. So you can get this error even though you have not set a layout.

At the time of my response, this is also the case for amp-img which do not support layout="container" - hence your error.

Layout Documentation

Fix your issue by adding width and height or specifying an appropriate layout.

like image 10
Chris McCowan Avatar answered Nov 16 '22 05:11

Chris McCowan


container is not supported by the layout attribute in <amp-img>. The AMP Docs provide a list of supported layouts you can use.

like image 2
Andrew Avatar answered Nov 16 '22 06:11

Andrew


This error occurs if we do not mention the width and height of an amp image. If the width and height attributes are not specified for an amp image (amp images must be given an explicit size as in width/ height in advance so that the aspect ratio can be known without fetching the image), the inferred layout is container which is not a supported layout for the same AMP Docs and so the error occurs.

like image 1
Deeksha Sharma Avatar answered Nov 16 '22 06:11

Deeksha Sharma