It seems that more and more social media sites use the Open Graph Markup to fetch metadata from pasted URLs, e.g. Facebook, LinkedIn and Pinterest. This issue is about adding Open Graph Markup support directly in XWiki headers.
A way to achieve this would be to add the snippet below to the page header, with the following caveats:
- Attachment external URL should be computed with the URL factory / API so that there is no need of $baseUrl.
- The home page should be computed via the XWiki APIs so that there is no need of hardcoded "Main.WebHome".
- The macro should use page references, not full names.
- Adding home page images may be needed only if current page has no attachment.
<meta property="og:url" content="$doc.externalURL" />
<meta property="og:type" content="article" />
<meta property="og:title" content="$tdoc.getRenderedTitle("plain/1.0")" />
#set ($hasImages = false)
#set ($page = $xwiki.getDocument($pageFullName))
#foreach ($attachment in $page.attachmentList)
#set ($hasImages = true)
#set ($url = $page.getAttachmentURL($attachment.filename))
<meta property="og:image" content="$baseUrl$url" />
## Add all page attachments that are images as og:image
## If current page has no attached image, add the ones of the home page
#if ($hasImages && $doc.fullName != "Main.WebHome")
What do you think?