Mobile app version of vmapp.org
Login or Join
Si4351233

: Why is my itemprop='image' markup incorrect? I've been experimenting with Microdata and thought I would try it on my blog. It turns out the template I was using already added some markup. It

@Si4351233

Posted in: #GoogleRichSnippetsTool #Microdata #SchemaOrg

I've been experimenting with Microdata and thought I would try it on my blog. It turns out the template I was using already added some markup. It wasn't great and so I fixed up what I could.

To try and push my luck I have added more markup to my latest post but Google's Structured Data Testing Tool (SDTT) is unhappy about the itemprop='image' attributes and I'm not sure why.



Results page.

It is my understanding, ignoring all the code in between, that I have structured the data thus:

<div itemscope='itemscope' itemtype='http://schema.org/BlogPosting'>
<div itemprop='articleBody'>
<a href="1.png" itemprop="url"><img itemprop="image sharedContent" src="1.png" /></a>
<a href="2.png" itemprop="url"><img itemprop="image sharedContent" src="2.png" /></a>
<a href="3.png" itemprop="url"><img itemprop="image sharedContent" src="3.png" /></a>
</div>
</div>


And this looks correct to me.
BlogPosting can have the properties articleBody and image according to schema.org/BlogPosting, but according to the SDTT:


The attribute itemtype has an invalid value.


Indeed, I have just tried the SDTT with the above example code and it is failing to validate.



So I'm obviously missing something. What am I doing wrong?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Si4351233

1 Comments

Sorted by latest first Latest Oldest Best

 

@Smith883

schema.org/BlogPosting image permits ImageObject and URL, however Google only permits ImageObject, hence the error. The intended markup is:



<!-- my code -->
<div itemprop="image" itemscope itemtype="http://schema.org/ImageObject">
<img src="image.jpg" itemprop="url">
</div>


               

Another discrepancy is schema.org/ImageObject recommends contentUrl, but Google recommends url, hence my usage above.



In response to your comment's code, your structure is still incorrect. I'll take it line by line:

<!-- your code -->
<div itemscope='itemscope' itemtype='http://schema.org/BlogPosting'>


Minor point, but unless you're going for XHTML, itemscope='itemscope' is wrong. Use itemscope (as you did later on).

<!-- your code -->
<div itemprop='articleBody'>
<div itemscope itemtype="http://schema.org/ImageObject"/>


Your ImageObject is a child of the articleBody property, but you haven't associated it in this way. Like this, you have an articleBody with no associated properties and an unassociated ImageObject. You should use

<!-- my code -->
<div itemprop="image" itemscope itemtype="http://schema.org/ImageObject">


Also, /> is incorrect, even if you are trying for XHTML as this element does have children and a closing </div>. Just use > as I included in the above snippet.

<!-- your code -->
<a href="1.png" itemprop="url"><img itemprop="image sharedContent" src="1.png" /></a>


What is sharedContent doing here? sharedContent expects a CreativeWork when used as a property of SocialMediaPosting — never as a property of ImageObject and never on an img.

Your other code snippet which places the sharedContent property as below is also wrong.

<!-- your code -->
<div itemscope='itemscope' itemtype='http://schema.org/BlogPosting'>
<div itemprop='articleBody'>
<div itemprop='sharedContent'>
<div itemscope itemtype="http://schema.org/ImageObject"/>



Whilst sharedContent is now in the right place, it still needs to be a CreativeWork. Your ImageObjects are still not associated with the BlogPosting, as shown by the Structured Data Testing Tool.

                                          

The following is the correct code.

<!-- my code -->
<div itemscope itemtype="http://schema.org/BlogPosting">
<div itemprop="articleBody">
<div itemprop="image" itemscope itemtype="http://schema.org/ImageObject">
<a href="1.png" itemprop="url"><img itemprop="image" src="1.png"></a>
</div>
<div itemprop="image" itemscope itemtype="http://schema.org/ImageObject">
<a href="2.png" itemprop="url"><img itemprop="image" src="2.png"></a>
</div>
<div itemprop="image" itemscope itemtype="http://schema.org/ImageObject">
<a href="3.png" itemprop="url"><img itemprop="image" src="3.png"></a>
</div>
</div>
</div>

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme