对文章中未显示的微数据使用不同的图像? [英] Using a different image for microdata that isn't displayed in the article?

查看:114
本文介绍了对文章中未显示的微数据使用不同的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个包含大量文章的网站。



我正在寻找一种方法来添加一个不可见的图像而不会将其放在隐藏的div中。



当用户添加文章时,用户上传的具体比例为主要图片我想用微数据)。还有其他图片会在他们上传的旋转木马中扔掉。

目前,我可以通过微软数据测试工具来使用自己的图片如下:

 < div class =hidden> 
< / div>

我想要做的是使用元标记,但这不是似乎工作:

 < meta itemprop =imagecontent =link / to / image.jpg > 

虽然Open Graph和Twitter Cards支持图片的元标记,但我还没有找到与微数据相关的任何内容。
是否有人知道微数据是否可行,甚至是否它的那个重要?



我只是不希望有一个隐藏的图像,如果可能的话加载时间!

解决方案

您可以使用 JSON-LD 来代替微数据。



通过这种方式,您可以将所需的所有内容添加到JSON数据中,但不会显示在页面中,但可被大多数搜索引擎识别。



下面是一个来自 http://schema.org/CreativeWork 的示例:

 < script type =application / ld + json> 
{
@context:http://schema.org,
@type:CreativeWork,
name:我的文章,
image:http://your.image.url.com
}
< / script>


I'm working on a website that has a bunch of articles.

I'm looking to find a way to add an image that is invisible without putting it inside a hidden div.

When users add an article, there is a "main" image of the specific proportions that the users upload (which I'd like to use for microdata). There are also other images that get tossed in a carousel that they upload.

At the moment the only way I can get the microdata testing tool to use my image is by doing the following:

<div class="hidden">
    <img itemprop="image" src="link/to/image.jpg" />
</div>

What I'd like to do is use a meta tag, but this doesn't seem to work:

<meta itemprop="image" content="link/to/image.jpg">

I haven't found anything relevant for microdata, although Open Graph and Twitter Cards support meta tags for images. Does anyone know whether its possible for microdata or not, or even whether its "that" important?

I just don't want to have a hidden image that adds to load times if possible!

解决方案

You can use JSON-LD instead of microdata.

That way you add everything you want in JSON data that is not displayed in the page, but recognized by most search engines.

Here is an example taken from http://schema.org/CreativeWork:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "CreativeWork",
  "name": "My Article",
  "image": "http://your.image.url.com"
}
</script>

这篇关于对文章中未显示的微数据使用不同的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆