有没有办法使用onerror属性<amp-img>
?
它在html中工作得很好.
<img src="../images/some-logo1.jpg" onerror="this.src='../images/no-img.jpg';" class="posting-logo-img">
Run Code Online (Sandbox Code Playgroud)
但是amp html会在amp-img中创建img标签
<amp-img src="/img/amp.jpg" alt="AMP" class="posting-logo-img" onerror="this.src='../images/no-img.jpg';" >
<noscript>
<img src="/img/amp.jpg" alt="AMP">
</noscript>
</amp-img>
Run Code Online (Sandbox Code Playgroud) 我在客户的网站上有很多<amp-img>
元素,最近注意到一个功能,您可以单击图像并弹出一个右上角带有 X 的灯箱。我在他们的官方文档中找不到任何关于启用/禁用此功能的提及。我将此元素用于某些背景/风格元素,因此我希望用户无法单击它。任何帮助深表感谢。
这是我正在使用的代码,删除了类和 URL:
<amp-img
width="2000"
height="515"
layout="responsive"
src="https://image.url">
<amp-img placeholder
src="https://placeholder.url"
layout="fill">
</amp-img>
</amp-img>
Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的应用程序中使用AMP。我可以通过以下方式获取图像:
\n\n<img src="{{url(\'storage/images\')}}/{{$post->image}}" alt="{{$post->title}}" class="img-fluid">\n
Run Code Online (Sandbox Code Playgroud)\n\n但由于我添加了 AMP,它们将不再加载:
\n\n<amp-img src="{{url(\'storage/images\')}}/{{$post->image}}" alt="{{$post->title}}" class="img-fluid"></amp-img>\n
Run Code Online (Sandbox Code Playgroud)\n\n知道发生了什么吗?
\n\n这是我添加到我的网站标题中的内容:
\n\n<html amp lang="{{ app()->getLocale() }}">\n<!-- amp -->\n <script async src="https://cdn.ampproject.org/v0.js"></script><!-- must besecond child -->\n <link rel="canonical" href="{{url()->current()}}">\n <script type="application/ld+json">\n {\n "@context": "http://schema.org",\n "@type": "NewsArticle",\n "headline": "Open-source framework for publishing content",\n "datePublished": "2015-10-07T12:02:41Z",\n "image": [\n "logo.jpg"\n ]\n }\n </script>\n <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 …
Run Code Online (Sandbox Code Playgroud)