问题
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