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.
 
In my opinion, the blue background is better to clearly distinguish that it's embedded content.
Screenshot 2023-12-13 192253.webp


does it get a button that can be added to the toolbar in post editor?
Any reason why not? It's always good to have a choice in the matter.

Nice. I disabled URL unfurling on my forum because I don't want it to be automatic (and I don't think there was any info telling you that it only does it when a link is on its own line). Even though this embed option isn't exactly the same, it seems like it should be the "manual URL unfurling" I've been wanting.

If I understand correctly, the limitation/difference is that the embed option only works for content on your forum, and looks a bit different?
 
ok. so this is probably already answered in the thread. i went through the five pages but i didn't find anything relevant. i understand that external embedding would only work for publicly accessible content. but would internal embedding work for posts in private forums? would the embeds load at least for users who have access to those private forums? or would it fail for all? or work for all?
 
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.
The API response seems to be missing required fields width and height, I've reposted this as a bug.

 
Is there any way to share a post with an image in XF 2.3 to Facebook or Twitter or LinkedIn ?

LinkedIn appears to pick up the OpenGraph image, but Twitter and Facebook don't
 

There's the thread. Find the comment.
 
So I skimmed the whole thread and assume this is the purported post:


However, he's talking about using a webhook to autopost to twitter. There is no mention or claim pertaining to Twitter rendering an image.
 
I think the og:image on social media has been an issue since 2.1/2.2.
I used Joyfreaks nice add-on, but that doesn't seem to work yet on 2.3, hopefully it will come along.

Sharing is a basic functionality that should be possible without having to revert to embed codes.
 
Outstanding Job XF Team! So easy to implement custom embed resolvers! Also so easy to get embeds resolving within custom content type displays thanks to the EmbedRendererTrait ;)

Would be nice to see how easy / customizable the embeds will be!
Beyond easy as each Embed Resolver has its own unique template.

Don't like what the output looks like for posts, edit the embed_resolver_post template and customize it to how you want it to look.

Don't like what the output looks like for threads, edit the embed_resolver_thread template and customize it to how you want it to look.

Don't like what the output looks like for resources, edit the embed_resolver_resource template and customize it to how you want it to look.

Don't like what the output looks like for media items, edit the embed_resolver_xfmg_media template and customize it to how you want it to look.

Filter the templates list by 'embed_resolver' and you will see all of the templates for XF (and XFRM and XFMG if you have those addons installed).

Any Content Type can implement an Embed Resolver, so if you have for example, Showcase installed, it includes 5 Embed Resolvers (Items, Item Updates, Item Pages, Item Reviews and Series), each with their own embed resolver template.

I implemented 40+ Embed Resolvers over the weekend and its so nice that you can design the output to the content vs being forced to display all content via a generic BLAH output.
 
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:

View attachment 293253

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:

View attachment 293254

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

View attachment 293255

Resources and resource updates:

View attachment 293256

View attachment 293257

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

View attachment 293258
View attachment 293259

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>

View attachment 293260

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

View attachment 293261

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