2

Ho to use Schema.org in the caption of an image?

I see that caption is not present in BlogPosting nor Article. I made a search and it seems that it is in ImageObject.

But if I am inside itemscope Article, can I use itemprop="caption"? I mean, can I use the code example below?

<div itemprop="caption">Caption of the image</div>

If not, how to use caption inside Article or BlogPosting?

<div itemscope itemtype="http://schema.org/Article">

<img itemprop="image" src="1.png">
<div>Caption of the image</div>
<h1 itemprop="headline name" >Title of the post</h1>
<div itemprop="datePublished" content="2016-01-07" >2016-01-07</div>
<div itemprop="articleBody" >       
    <p>This is the body of the post</p>
</div>

</div><!-- end schema Article -->
2

You have to provide an ImageObject item, and you have to add the caption to this ImageObject item. Otherwise you would add the caption to the Article, which is not what you want (and caption isn’t defined for Article anyway).

So in Microdata it could look like:

<div itemscope itemtype="http://schema.org/Article">

  <!-- Article properties here -->

  <div itemprop="image" itemscope itemtype="http://schema.org/ImageObject">
    <!-- ImageObject properties here -->
    <p itemprop="caption">Caption of the image</p>
  </div>

  <!-- Article properties here -->

</div>
  • I find confusing that there is an itemprop="image" in Article. So I can use it there. – Nrc Aug 22 '16 at 15:51
  • @Nrc: What do you find confusing about this exactly? The image property in an Article item adds an image of the article. Where else should the image be? – unor Aug 22 '16 at 17:04
  • In your code it seems that itemprop caption is a subclass inside itemprop image. But in schema image and caption are at the same level: schema.org/ImageObject – Nrc Aug 23 '16 at 7:54
  • @Nrc: itemprop is for adding properties (like image, caption), not classes (like Article, ImageObject). In my example, the Article item has one property (image), which has an ImageObject item as value. This ImageObject has also one property (caption), which has text as value. -- If you would add an image property to the ImageObject item (on the same level like caption), you would add an image of an image, which is probably not what you want. -- With "at the same level", do you mean the properties listed in the table? It only means which properties this type may have. – unor Aug 23 '16 at 9:11
  • Can you say how would it be with all the code I give as example, please? – Nrc Aug 23 '16 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.