javascript - 获取 AMP 图片 url 的条件标记

标签 javascript html blogger google-search-console accelerated-mobile-page

在 Blogger 中,我使我的网站得到支持,为此,在我的帖子中,我更改了所有 <img to <amp-img . 但在结构化数据中,我使用以下代码:

<div class='none' itemprop='image' itemscope='itemscope' itemtype='https://schema.org/ImageObject'>
      <b:if cond='data:post.firstImageUrl'>
        <amp-img expr:src='data:post.firstImageUrl' itemprop='image'/>
        <meta expr:content='data:post.firstImageUrl' itemprop='url'/>
      </b:if>
      <meta content='800' itemprop='width'/> <!--Images should be at least 696 pixels wide.-->
      <meta content='800' itemprop='height'/>
    </div>   
每当我在结构化数据测试工具中检查此工具时。以上代码无法提取<amp-img URL,因为它用于提取 <img仅限网址。 我该如何解决这个问题?

最佳答案

在许多论坛上进行大量搜索后,我找到了我的问题的解决方案。在后期使用中 <amp-img来自 amp guideline 的 NoScript .

<amp-img src="images/sunset.jpg"
  width="264"
  height="195">
  <noscript>
    <img src="images/sunset.jpg" width="264" height="195" />
  </noscript>
</amp-img>

这可以是您图像的两个版本,一个是放大器,另一个是非放大器。

关于javascript - 获取 AMP 图片 url 的条件标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45429717/

相关文章:

javascript - 用随机值填充数组

javascript - 为什么在 Vue 中从数组中删除元素时会在最后一个索引处发生转换?

html - 如何在具有溢出滚动的父元素中包含子元素的边距?

html - 尝试在博客上上传我自己编写的代码时如何修复 "Could not load theme preview: Error parsing XML,"

javascript - 如何将 CSS 样式应用于由我无法控制的 Javascript 脚本注入(inject)和设置样式的 HTML

javascript - 使用 jquery 用户代理检测隐藏页面元素在 Android 中速度较慢但在 iOS 中不慢 - 如何修复?

javascript - 如何将数字四舍五入到小数点后八位并使用不同的颜色?

javascript - 你能用 @ 符号包装文本吗?

html - 不固定高度的滚动条/带滚动条的动态高度

javascript - 如何在 Blogger 中添加 Javascript?