简体   繁体   English

是否通过AMP-List返回整个图像?

[英]Return entire images via AMP-List?

We are attempting to return the entire image tag via AMP-List, rather than just the source URL. 我们正在尝试通过AMP-List返回整个图像标签,而不仅仅是源URL。

Example: 例:

AMP-List Markup: {{{amp_image}}}
JSON Returned: {"amp_image":"<img src='example-img.png' />"}

However, with this example and many variations - no image seems to be returned. 但是,通过此示例和许多变体-似乎没有图像返回。 Is what we're doing possible, or is there some limitation where images cannot be displayed after the fact? 我们正在做的事情是否可能,或者存在某些限制,使得事后无法显示图像?

The main reason we're attempting to return the entire image rather than just the source, is that some of our AMP pages are being 'flagged' (via SEMRush and others) as having 404's. 我们尝试返回整个图像而不仅仅是源图像的主要原因是,我们的某些AMP页面(通过SEMRush等)被“标记”为404。 It seems that they see rather than the actual src, since it's returned via JS - which results in the 404. 似乎他们看到的不是实际的src,因为它是通过JS返回的-导致404。

Thanks in advance for any input here! 在此先感谢您的任何输入!

What you're looking for is a way to return unescaped HTML from a mustache templates. 您正在寻找的是一种从胡子模板返回未转义的HTML的方法。 Per Mustache documentation the way to do this is using "triple-mustache" syntax, ie {{{unescaped HTML}}} . 根据Mustache文档 ,执行此操作的方法是使用“三重胡子”语法,即{{{unescaped HTML}}}

AMP, however, places some restrictions on this (from Restrictions section of amp-mustache documentation ): AMP,但是,对此设置了一些限制(来自amp-mustache文档的“ 限制”部分 ):

The output of "triple-mustache" is sanitized to only allow the following tags: a , b , br , caption , colgroup , code , del , div , em , i , ins , li , mark , ol , p , q , s , small , span , strong , sub , sup , table , tbody , time , td , th , thead , tfoot , tr , u , ul . 将“ triple-mustache”的输出进行清理以仅允许以下标签: abbrcaptioncolgroupcodedeldivemiinslimarkolpqssmallspanstrongsubsuptabletbodytimetdththeadtfoottruul

So the syntax you're using is valid, but amp-img is not among the tags allowed in "triple-mustache" templates. 因此,您使用的语法是有效的,但amp-img不在“三重胡子”模板允许的标记之中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM