使用JavaScript将图像URL复制到Schema Microdata

时间:2017-02-13 02:39:43

标签: javascript schema.org microdata

我有一个包含多个图像的页面,我想添加微数据。我的HTML按以下方式构建:

<article class="photo">
  <div class="post__content">
    <a href="http://example.com/page">
      <img class="post__img" src="http://example.jpg">
    </a>
  </div>
</article>

图像的url是动态生成的,所以我想创建一个复制URL的脚本,并将其添加到相应的模式条目下:

{
  "@type": "ImageObject",
  "contentUrl": "http://example.jpg"
}

我找到的最接近的例子是How can I copy a URL from an image's src attribute to an href attribute in jQuery?。但是,我不确定如何修改上述概述。

0 个答案:

没有答案