XF 2.3 Embed your content anywhere

This week, we're delighted to introduce a new feature in XenForo 2.3 that enhances the way you can share content on your forum. Plus, we'll show you how easy it is to share any content from your forum to other platforms using our new content embedding feature.

Rich previews for content​

If you're already familiar with URL unfurling, content embedding works similarly. In XenForo 2.2, when you post a link to content on your forum, we perform an HTTP request, download a portion of the content, and extract metadata such as the page title, description, and a logo. If you need a refresher on URL unfurling, you can find our original announcement from XenForo 2.1 here:


While URL unfurling works well for content from other sources, for content already on your forum, we're introducing a new [EMBED] BB code. This fetches a rich preview directly, and is added to your content automatically on save if you paste a link (on its own line). This is what it looks like:

hys_7_content_embed_1.png


A minor inconvenience with the unfurl system when sharing content on your forum is that it sometimes misses the context. For example, if you link to a specific forum post, the unfurl system retrieves metadata from the thread instead of the post itself. With our new content embedding system, this issue is resolved. Now, when you want to feature a specific post, the system generates a rich preview of that post, preserving the context and enhancing the viewer's experience:

hys_7_content_embed_2.png


Of course threads and posts are not the only content supported. You can also embed profile posts:

hys_7_content_embed_3.png


Resources and resource updates:

hys_7_content_embed_4.png


hys_7_content_embed_5.png


And, of course, media items and albums which are mostly the same as they were previously with the existing [GALLERY] tag:

hys_7_content_embed_6.png

hys_7_content_embed_7.png


You might already be thinking about the possibilities this opens up for developers. As always, developers are welcome to add support for their own content types in the usual way.

We're eager to hear what you think about these updates. But don't go just yet; we've got more to share.

Embedding content anywhere​

In addition to improving how you highlight content on your forum, you can now also embed your content on other forums or even non-XF content management systems.

Included in XenForo is a new script named embed.php. This script allows your content to be rendered anywhere, as long as it's visible to guests. All you need is the content type and ID and an iframe:

HTML:
<iframe src="https://xenforo.com/community/embed.php?content=thread-216767" frameborder="0" width="560"></iframe>

hys_7_content_embed_8.png


For a more accessible approach, you can find the embed code for a specific item under the share tooltip (where available):

hys_7_content_embed_9.png


This version of the embed code looks like this:

HTML:
<div class="js-xf-embed" data-url="https://xenforo.com/community" data-content="thread-216767"></div>
<script defer src="https://xenforo.com/community/js/xf/external_embed.js?_v=ab87d886"></script>
This embed code does the same job as the iframe, but with a little extra magic to make sure the iframe sizes itself perfectly to fit the content.

This new ability to externally embed content means you can now implement a BB code media site in your XenForo forum to automatically embed content from other XenForo forums!

Furthermore, starting with XenForo 2.3, we're introducing a new oEmbed endpoint to our REST API. This endpoint doesn't require authentication and is always available. For example, a request to https://xenforo.com/community/api/oembed/?url=https%3A%2F%2Fxenforo.com%2Fcommunity%2Fthreads%2Fboosting-performance-in-xenforo-2-3.216767%2F will produce the output:

JSON:
{
    "version": "1.0",
    "type": "rich",
    "provider_name": "XenForo community",
    "provider_url": "https://xf.deemit.site/community",
    "author_name": "Chris D",
    "author_url": "/community/members/chris-d.11388/",
    "html": "<div class=\"js-xf-embed\" data-url=\"https://xenforo.com/community\" data-content=\"thread-216767\"></div><script defer src=\"https://xenforo.com/community/js/xf/external_embed.js?_v=ab87d886\"></script>",
    "referrer": "",
    "cache_age": 3600
}

In addition to oEmbed making it easier to embed your content on other XenForo forums, it will also make it easier to post your content almost anywhere. For example, if you were to get your forum approved by Embed.ly, your content could end up being shared with rich previews on platforms such as Reddit, and many more!

That wraps up this week's HYS! We look forward to hearing your feedback and will be back with more next week.
 
I'm not sure I fully understand the request. Are you requesting that group A be prevented from embedding content type X but allowed to embed type Y, while group B can embed both?
Partly.

When we started to promote some forum content though our forum linked social media accounts (Facebook, Instagram, X/Twitter) wo got massive complaints from our members, they did not want their content to appear on those platforms.

We explained that there basically is no way to achieve this as anyone could just copy a URL and post it on those platforms but they didn't care.

So what we did was to give them an option to opt-out from "Social Sharing" on a per content basis (with an accout-based default setting).

Now if they see an embed option on pretty much every content I can imagine we could get a lot of protest / anger... again :(

To avoid this it would be great if we had granular control as to which content can be embedded externally, so for example

  • Content type option
    (Use case: We would not want any profile posts to be embedded on any 3rd party websites)
  • Forum option
    (Use case: No user from any usergroup would want their "cat farewell thread" to be embedded somewhere else)
  • Nodebased permission
    (Use case: Some usergroups might not want their classifieds embedded on other websites)
  • Per content user option
    (Use case: Some users might not want e specific media item to be embedded on a 3rd party website

All this refers to external embedding only.
 
Last edited:
Forum option
(Use case: No user from any usergroup would want their "cat farewell thread" to be embedded somewhere else)
Another use case: I have looked in the past at moving my stories to an article forum on my Xenforo site (current site is getting sleepy and I would like to have them somewhere where I have more control over them). I would not want that content embedded elsewhere, just linked, so would want embedding turned off for that article forum. Though I guess someone like Bob could add that kind of protection to an AMS-type product.

Overall, though, I see potential for this, esp. if we want to revive our site's social media presence.
 
I read it as the admin wanting permission control to expose some public content (threads from specific nodes for example) to embedding while restricting other public content (threads from other nodes, or media resources) from the embedding system.

BTW - Hell yeah! Looks great.
Yes I have some content that only paying members can see. Wouldn't want that to be possible to see elsewhere with an embed.
 
this is the actual embedded content...

https://xenforo.com/community/embed.php?content=thread-216767

in the end you can just add a caching point for embed.php?*. not sure if the same method is used for internal embedding.
 
Included in XenForo is a new script named embed.php.
Does embed.php set X-Robots-Tag: noindex and Link: <https://...>; rel=canonical (or equivalent in generated HTML)?

If not this should be considered.

Or maybe even return a plaintext 403 for robots (with those headers).
 
I feel like the design being so generic defeats a large portion of why you want to embed your content on an external site, which is to encourage engagement.

Why were cues not taken from Twitter (https://help.twitter.com/en/using-x/how-to-embed-a-post) or even Facebook (https://developers.facebook.com/docs/plugins/embedded-posts/)?

As much as I personally do not like Twitter, especially with what it has become, its rich embed is among the most usable and would translate well to XF. Even just taking cues for presentation would greatly impact the usefulness of external embeds.

How customizable will embeds be design wise? Will it be possible to replace the default embeds with an add-on?
 
I feel like the design being so generic defeats a large portion of why you want to embed your content on an external site, which is to encourage engagement.

Why were cues not taken from Twitter (https://help.twitter.com/en/using-x/how-to-embed-a-post) or even Facebook (https://developers.facebook.com/docs/plugins/embedded-posts/)?

As much as I personally do not like Twitter, especially with what it has become, its rich embed is among the most usable and would translate well to XF. Even just taking cues for presentation would greatly impact the usefulness of external embeds.

How customizable will embeds be design wise? Will it be possible to replace the default embeds with an add-on?
^ This. Would be nice to see how easy / customizable the embeds will be!
 
Embedding XenForo widgets into WordPress would be awesome. Suggestion added here:
 
Last edited:
Back
Top Bottom