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.
 
Support for internal embedded is great :)

But I am a bit concerned about external embedding:
Will there be settings for users and / or permissions to control which guest accesible content can be embedded on 3rd party websites?

Some users (and / or) admins may not want (all) content to be embeddable on 3rd party websites.
 
Nice. Though I suppose this doesn't fix existing problems with unfurl limitations that fails on sites like wapo and cnn coz the relevant meta data is too down the code. But good to see this. Maybe full quotes could be replaced with embeds as well 👍🏽 which would keep them updated with edits. Complex to implement though I suppose. Thanks!

 
Last edited:
Support for internal embedded is great :)

But I am a bit concerned about external embedding:
Will there be settings for users and / or permissions to control which guest accesible content can be embedded on 3rd party websites?

Some users (and / or) admins may not want (all) content to be embeddable on 3rd party websites.
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?
 
Full quotes IMHO are s bad habit anyway and should not be encouraged.
So: Please do not implement this :)
Well folks are going to click on reply and quote full content anyways. It becomes a problem with removing usernames and other personal information which spreads to multiple places. Not to mention dead embeds like tweets and YouTube videos. If embeds are used for reply button, at least that problem is sorted. Having quoted post content as part of post content is sort of crazy when everyone quotes the posts like on communities like XDA 🫣
 
Looks nice. :cool:

Is the embedding automatic if the domain is self-referenced instead of being unfurled? So if I post a link to another thread here at XF will it be smart-enough to be embedded or would I need to explicitly use the embed tag?
 
It becomes a problem with removing usernames and other personal information which spreads to multiple places.
Automatic parsing of the current username would be a good solution. Currently the quote bbcode has the username. It would be much better if the userID would be used and the username parsed from it. IIRC vbulletin did that.
So that when a username change or a GDPR request is processed, all quotes are updated to the correct username. And the same for mentions. Currently it displays the wrong username which looks buggy.

IMHO something like that would be a better solution than embedding.
 
Maybe full quotes could be replaced with embeds as well 👍🏽 which would keep them updated with edits. Complex to implement though I suppose.
Would also cause a ton of server overhead. You would cause an additional HTTP request for every quote on the page, you would need to load the full application stack and authenticate users for every embed, etc. Say you are including 300 PHP files and doing 2 queries per quote if done that way... what if you had 20 quotes visible on the page? Would you really want to add 20 HTTP requests, 40 queries and 6,000 PHP file includes to the page? Doesn't seem like it's worth it to me.
 
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?

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.
 
Back
Top Bottom