Onebox for WordPress 4.4 sites


(Adam Capriola) #1

Onebox used to work great for my site, but last week (I’m pretty sure after I upgraded to 4.4) it stopped working so nicely:

The Iframely previews look ok except for the oEmbed HTML — it looks weird.

This seems relevant: New Embeds Feature in WordPress 4.4 – Make WordPress Core

I guess there’s a plugin to disable the new embed functionality, but I doubt many people are going to think of doing (or want to do) that.


(Jeff Atwood) #2

Sure, we should support both earlier WordPress and WordPress 4.4 here @techapj can you add to your list?


(Arpit Jalan) #3

The above WordPress onebox looks good on try:

It’s broken here on meta because http://sixprizes.com (WordPress blog) does not have SSL enabled, hence causing this error:

Mixed Content: The page at 'https://meta.discourse.org/t/onebox-broken-for-wordpress-4-4-sites/36765/2' was loaded over HTTPS, but requested an insecure resource 'http://sixprizes.com/2015/12/15/silver-surfer-back-to-back-runner-up-reports-a-fiery-standout-and-some-potential-plays/embed/'. This request has been blocked; the content must be served over HTTPS.

@AdamCapriola If your Discourse instance has SSL enabled than the accompanying WordPress blog should also have SSL enabled for embeds to work properly.


(Adam Capriola) #4

Oh, huh. Maybe they are working. The only other link I’d showed up like this and I assumed something was broken:

I guess the height is just off (the title and except aren’t shown — featured image is too big). Is that a WordPress issue?


(Jeff Atwood) #5

Also http://blog.discourse.org is latest WordPress so we can test with that too.

We’re supposed to onebox URLs in the form

http://blog.discourse.org/2015/12/discourse-selected-for-mozilla-open-source-support-program/

Where it is
http://example.com/yyyy/mm/slug/

Because we assume they are WordPress…

Why isn’t that happening, @techapj?


(Arpit Jalan) #6

Currently we were only oneboxing WordPress links with ../yyyy/mm/dd/.. permalinks, just added support for ../yyyy/mm/.. permalinks too:


Posts from http://blog.discourse.org are still not getting oneboxed because we are not providing oEmbed endpoint, will modify our WordPress theme to include oEmbed endpoint for posts.


(Arpit Jalan) #7

Seems like it… Here is the WP iframe source: “Build-A-Bat” – Crafting Crobat for Competitive Play, Meta Updates, and Rogue Highlights

Notice that there is no max-width CSS property on image, and the iframe height is fixed height="338".


(Adam Capriola) #8

Hmm. Yeah idk why the height is wrong. The image size is actually ok. When I try to embed the post in WordPress it looks fine.

Either way, the blockquoted link above the embed should be hidden, right?

blockquote.wp-embedded-content {
    display: none;
}

Height appears to be 338 for anything (notice the whitespace below this embed):

It resizes inside of WordPress posts though (visit that link and watch the page load). So maybe there’s something going on in Discourse preventing it from resizing correctly?


Post with CDATA block produces invalid RSS feed?
(Jeff Atwood) #9

We absolutely do not want embedded variable height content as it destroys our infinite scrolling – ask @techapj about Twitter embeds for this reason. If it is variable height, it cannot be allowed.


(Adam Capriola) #10

Got it. So I guess for consistency we want to enforce WordPress links as they behaved previously then? (OpenGraph instead of oEmbed)

Is that possible or is this in the hands of the WP install?


(Jeff Atwood) #11

It needs to behave like Twitter where we grab the content and render it. We cannot have alien Iframes of varying height ruining all scrolling.


(Arpit Jalan) #12

Okay, I just fixed this issue via

Now in case of WordPress embeds onebox will use OpenGraph data instead of oEmbed (so as to avoid weird iframes).


Here’s the above WordPress link with OpenGraph data: