Amp-img error: layout not supported for: container

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

I get an error: Layout not supported for: container
Error in console: The specified layout 'CONTAINER' is not supported by tag 'amp-img'

Not sure what this error means.

So far, I can not find anything in the documents associated with this error message.

+8
amp-html
source share
4 answers

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

+2
source share

According to google AMP docs, the following layouts are 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/

Therefore, 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> 
+10
source share

Amp defaults to layout = "container" if the width and height attributes are not set. That way you can get this error even if you haven't installed the layout.

At the time of my answer, this also applies to amp-img, which do not support layout = "container" - hence your mistake.

Layout documentation

Fix the problem by adding width and height or by specifying the appropriate layout.

+10
source share

This error occurs if we do not mention the width and height of the amplifier image. If the width and height attributes are not specified for the amp image (amp images must be explicitly set in advance as width / height so that the aspect ratio can be known without extracting the image), the intended layout is a container that is not supported by the layout for the same AMP document , therefore an error occurs.

+1
source share

All Articles