XF 2.3 Replacing Embedly with Unfurled Links after Importing from VB4

shri

Member
I have a large forum which relies on embedly to provide previews of links. This is extremely useful for our members who just want a short preview of the article linked, or in many cases when discussing things like movies and TV shows, watch YouTube videos directly, or see posts from X / Reddit without having to click through.

This is what a current post looks like and I am posting this just to demonstrate that I think unfurling old posts has some value to our forum.

Screenshot 2024-07-02 at 11.12.00 AM.webp

Please correct me if I am wrong - I have just completed importing a test forum from VB4 to XF 2.2 and plan to upgrade to XF 2.3RC5 shortly.

1) Unfurl provides this functionality, but for new posts on XF and not imported posts.
2) There is currently no way to run even a slow batch process to progressively unfurl the links and replace the functionality of embedly.

Questions:

1) Ideally, would love to be able to move away from embedly, but I guess I can use CSS classes / JS to manipulate embedly to work as before on posts that are not unfurled after the import.

2) Am I missing something in my research and is there an add on or has someone developed a cli script to refresh old posts which have external / internal links in the post content?

Thank you in advance!
 
Incase this helps ... this is how we use embedly in VB4.

Our postbit content is vanilla - no modifications from what you'd expect from vBulletin. We do a little bit of work on the render side.

Here's what our VB plugin looks like and it runs on

Code:
postbit_display_complete

And prepares the post for using embedly cards. ( https://docs.embed.ly/reference/cards )

I assume I could write a plugin / add-on of sorts on XF and maintain the embedly code as is. Just want to see if there is a unfurl solution before I venture down this path and figure out how to write XF addons etc.

PHP:
$dom = new DOMDocument();
$dom->loadHTML(mb_convert_encoding($this->post['message'], 'HTML-ENTITIES', 'UTF-8'));

$xpath = new DOMXPath($dom);
$nodeList = $xpath->query("//a[contains(@href, 'domain.com/classifieds') and not(contains(@href, 'noembed'))]|//a[contains(@href, 'domain.com/directory') and not(contains(@href, 'noembed'))]|//a[contains(@href, 'domain.com/articles')]|//a[not(contains(@href, 'domain.com')) and not(contains(@href, 'bloomberg.com')) and not(contains(@href, 'noembed')) and not(contains(@href, 'mailto')) and not(contains(@href, 'tel:')) and not(contains(@href, 'attachment.php')) and not(contains(@href, '#post'))]");
$forceList = $xpath->query("//a[contains(@href, 'forceembed')]");

$i = 0;
foreach ($nodeList as $node) {
    if ($node->parentNode->getAttribute('class') != "message") {
        $node->setAttribute('class', 'embedly-card');
        $node->setAttribute('data-card-analytics', '1');
        $node->setAttribute('data-card-controls', '0');
        $node->setAttribute('data-card-chrome', '1');
    }
    if (++$i > 3) break;
}

foreach ($forceList as $fnode) {
    if ($fnode->parentNode->getAttribute('class') != "message") {
        $fnode->setAttribute('class', 'embedly-card');
        $fnode->setAttribute('data-card-analytics', '1');
        $fnode->setAttribute('data-card-controls', '0');
        $fnode->setAttribute('data-card-chrome', '0');
    }
}

$this->post['message'] = str_replace('mobile.twitter.com', 'twitter.com', $dom->saveHtml());
 
So, not an expert but some crude things I have done in the past. I haven't seen any way to process old posts to make them load as if they were posted manually to unfurl links and embed media links that might be stuck in text form after an import. i think i moved to xenforo around 14 years ago and i still find old posts that have raw links to youtube and tweets. I actually need exactly this to process old image embeds through proxy on 2.3 so that Xenforo can record their dimensions and use them to reduce layout shift.

Recently I changed my core domain and while I had proper redirection in place, I wanted to change references to old URL in all posts on the site. So I did a basic find and replace and all links were updated. But to get unfurls working lol. I extracted the links to the domain from the database table. And just pasted them in post editor in batches of 100s and clicked on preview (👀). Preview button in this editor process links just like it would on posting. Data is added to database and existing links in old posts use the data.

This probably would not work for you because your links are likely not collected in a centralized location.
 
Back
Top Bottom