How to add an image to an event with Microdata meta tag?

▼魔方 西西 提交于 2019-11-26 00:49:54

问题


Using microdata, is there a way to add an image into an Event by using a meta tag?

In the official Microdata site I see the option of adding images to events:

<img itemprop=\"image\" src=\"image.jpg\" alt=\"An image\"/>

which works fine. However, I wonder if it is possible to add that image by using something like:

<meta itemprop=\"image\" src=\"image.jpg\"  />

which according to my tests does not work.


回答1:


Instead of using the meta element, you must use the link element (because the value is a URI):

<link itemprop="image" href="image.jpg" />

This is required by HTML5 (bold emphasis mine):

The meta element represents various kinds of metadata that cannot be expressed using the […] link […] elements.

And it’s also explicitly required by Microdata.




回答2:


I just found the answer myself. For the record, meta tags must specify their value with the content attribute:

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


来源:https://stackoverflow.com/questions/24638451/how-to-add-an-image-to-an-event-with-microdata-meta-tag

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!