Implemented Add MediaObject structured data

dutchbb

Well-known member
Something like this? (media_view)

Code:
<script type="application/ld+json">
{
  "@context":"http://schema.org",
  "@type":"MediaObject",
  "mainEntityOfPage": {
    "@type":"WebPage",
    "@id":"{xen:link 'canonical:xengallery', $media, 'page={$page}'}"
  },
  "headline":"{$media.media_title}",
  "image": {
    "@type":"ImageObject",
    "url":"{xen:link 'canonical:xengallery/full', $media}"
  },
  "datePublished":"{xen:date $media.media_date, 'Y-m-dTh:m:s+01:00'}'}",
  "interactionStatistic": {
    "@type":"InteractionCounter",
    "interactionType":"http://schema.org/CommentAction",
    "userInteractionCount": "{xen:number $media.comment_count}"
  }
}
</script>
 
Last edited:

Chris D

XenForo developer
Staff member
This has been added to XF2 already.

We use ImageObject for images:
https://search.google.com/structured-data/testing-tool/u/0/#url=https://xenforo.com/community/media/pexels-photo-jpg.2166/

MediaObject for embeds:
https://search.google.com/structured-data/testing-tool/u/0/#url=https://xenforo.com/community/media/s%C3%BCper-%C3%B6tesi-duygusal-romandik-%C3%87inli-halk-t%C3%BCrk%C3%BCs%C3%BC.2139/

And for videos:
https://search.google.com/structured-data/testing-tool/u/0/#url=https://xenforo.com/community/media/lily-likes-animoji.2047/

And AudioObject for audio:
https://search.google.com/structured-data/testing-tool/u/0/#url=https://xenforo.com/community/media/kalimba-mp3.1903/

Why don't we use VideoObject for videos? Good question. It never worked. Although we met all of the requirements for the VideoObject structured data, we could never get it to successfully verify in the structured data testing tool. So we use MediaObject instead, and I check periodically whether anything has changed but alas the errors keep being reported so it's likely best we stick with MediaObject for now.
 

dutchbb

Well-known member
Great! ;) (forgot to check xf2).

Yeah i tried VideoObject also for youtube (in threads) but no luck. In media gallery did not try, but MediaObject is also fine for video's.
 

dutchbb

Well-known member
@Chris D

Would it be an idea to use ImageObject for attachments in posts? Not sure if video's and proxy images can be done like that.

Like so, or 'Thing' -> itemprop="image" because no extra data is given.
Code:
<div class="messageContent" itemscope itemtype="http://schema.org/ImageObject">
      <article>
            <blockquote class="messageText SelectQuoteContainer ugc baseHtml">

Echt of nep?
<br /><br />
<img src="http://..." itemprop="image" alt="20180403_022649.jpg" class="bbCodeImage LbImage" />
<br /><br />
<img src="http://..." itemprop="image" alt="20180403_022701.jpg" class="bbCodeImage LbImage" />
<br /><br />
<img src="http://" itemprop="image" alt="20180403_022711.jpg" class="bbCodeImage LbImage" />
               
                    <div class="messageTextEndMarker">&nbsp;</div>
              </blockquote>
          </article>

  </div>
 
Last edited:

dutchbb

Well-known member
ImageObject with the width and height would be best i think.

Why is ask is because for DiscussionForumPosting an image can be used in search results. At the moment the thread starter avatar or logo is used but is sometimes to small. Google states it could use an image from the article/thread instead.

Using ImageObject with extra data like dimensions could increase the chance maybe?
 

dutchbb

Well-known member
That does not work :p Structured data on xf2 is pretty complete so nothing to add anymore.
 
Top