amp-img错误:不支持布局:容器

Ken*_* Ma 8 amp-html

试图验证我的amp-img.在这个例子中:http://staging.laineygossip.com/Sasha-Celeb-Finds-Sienna-Miller/Lifestyle/24695/amp#development=1

我收到错误:Layout not supported for: container
在控制台中,错误是:The specified layout 'CONTAINER' is not supported by tag 'amp-img'

不确定这个错误意味着什么.

到目前为止,我在文档中找不到与此错误消息相关的任何内容.

Kse*_*nia 10

根据谷歌AMP文档,支持布局:

填充,固定,固定高度,FLEX-ITEM,NODISPLAY,响应

另外看看这个例子,我认为你不需要围绕布局类型的引用:https://ampbyexample.com/samples_templates/news_article/

所以看起来应该是这样的:

  <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>
Run Code Online (Sandbox Code Playgroud)


Chr*_*wan 10

如果没有设置width和height属性,Amp默认为layout ="container". 因此,即使您尚未设置布局,也可能会出现此错误.

在我的回复时,这也是amp-img的情况,它不支持layout ="container" - 因此你的错误.

布局文档


And*_*rew 2

containerlayout中的属性不支持<amp-img>AMP 文档提供了您可以使用的受支持布局的列表。