Make WordPress Core

Opened 9 years ago

Closed 8 years ago

Last modified 5 years ago

#34737 closed enhancement (fixed)

Add Facebook oEmbed support

Reported by: pento's profile pento Owned by: johnbillion's profile johnbillion
Milestone: 4.7 Priority: normal
Severity: normal Version:
Component: Embeds Keywords: has-patch
Focuses: Cc:


Facebook are in the process of releasing their oEmbed support - documentation has been written, it's really just the announcement that needs to be made.

Attachments (2)

34737.diff (1.8 KB) - added by pento 9 years ago.
34737.2.diff (1.9 KB) - added by pento 9 years ago.

Download all attachments as: .zip

Change History (32)

9 years ago

#1 @pento
9 years ago

  • Keywords has-patch 2nd-opinion added
  • Owner set to pento
  • Status changed from new to assigned

This is currently blocked by #34698.

@wonderboymusic: I know it's a bit late, but assuming that bug is fixed before RC 1, how do you feel about this landing in 4.4?

#2 @pento
9 years ago

  • Keywords 2nd-opinion removed
  • Milestone changed from Awaiting Review to 4.4

Let's git r done.

#3 @GaryJ
9 years ago

  • Keywords needs-patch added; has-patch removed

I think those regexes need checking. For instance, I don't think:


will match the last two of (from FB documentation):{page-name}/videos/{video-id}/{username}/videos/{video-id}/{video-id}{video-id}

...due to there being an extra / before video. i.e. I think it should be something like:


although that would need refining further as it would also capture something like

Last edited 9 years ago by GaryJ (previous) (diff)

#4 @swissspidy
9 years ago

Facebook is not exactly known for keeping things in a backwards-compatible way. The Graph API is always changing, the WordPress plugin isn't supported anymore, .... Will the oEmbed endpoint still be available two years from now?

Besides that, Facebook's oEmbed response is not compliant with the specification:

  • There's an additional success property
  • The height property is sometimes null
  • The width property is 100% by default instead of a unit-less number


#5 @DrewAPicture
9 years ago

-1 on pushing this in the back door for 4.4. I don't see why this shouldn't go through the normal paces of any other provider we add to the list.

It doesn't seem like the endpoint is well-enough established yet and @swissspidy raises some valid concerns in comment:4.

#6 @helen
9 years ago

  • Milestone changed from 4.4 to Future Release

I am not okay with doing this in 4.4 - oEmbed changes are indeed small, but they still need to be tested, vetted, and established. This is not "established", and all of @swissspidy's points are valid and important.

9 years ago

#7 @pento
9 years ago

  • Keywords has-patch added; needs-patch removed

Good catch, @GaryJ - 34737.2.diff updates the regex patterns.

@swissspidy makes some good points. Some Automattic folks are working with Facebook on this, they're going to pass this ticket along, so the problems can hopefully be addressed.

#8 @swissspidy
9 years ago

Current status:

  • It seems they don't use width: 100% anymore and instead use a default width of 500 (pixels).
  • height is still null in some cases.

I think we could integrate it once the height bug is resolved. I can live with there being an unneeded success property in the response.

#10 @swissspidy
9 years ago

height is still null in some cases.

To clarify: height is only null in the posts endpoint; videos are fine.

#11 @swissspidy
8 years ago

Still the same problem with the height property for posts.

@pento Do you know if there are still some Automattic folks working with Facebook on embeds? Do Facebook embeds work on

#12 @pento
8 years ago

I don't think the height thing is an issue. It's contrary to the oembed spec, but Instagram does the same thing, and that doesn't cause problems.

Facebook embeds work correctly on

#13 @pento
8 years ago

  • Keywords needs-refresh 2nd-opinion added

I think we're at a point where we can only decide if this is going in or not. The URLs that Facebook originally defined haven't changed, so I think we can call it established, or stable.

I doubt they'd be willing to change the height property that they return, their JS handles all of that magic.

The patch needs some updates:

  • the .php parts of the regexes need to be changed to \.php
  • I'm inclined to start adding unit tests for all our trusted oEmbed providers - if their output changes, we should know about it. Building those tests (with Facebook as the first provider) may be out of scope of this ticket, though.

I'm +1 on commit, though I'd like to hear arguments either way.

#14 @swissspidy
8 years ago

Yeah probably for the best to include this in 4.7. It's only a minor issue and shouldn't stop us from improving the experience for users.

There's #32360 for oEmbed unit tests. See also #28507.

Happy to work on both refreshing this patch and adding the tests.

#15 @johnbillion
8 years ago

  • Keywords 2nd-opinion removed
  • Milestone changed from Future Release to 4.7
  • Owner changed from pento to johnbillion
  • Status changed from assigned to reviewing

#16 @johnbillion
8 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 38367:

Embeds: Add support for embedding Facebook posts and videos via oEmbed.

Fixes #34737
Props pento, GaryJ

#17 @johnbillion
8 years ago

In 38368:

Embeds: Add a missing regex delimiter for Facebook URLs.

See #34737

#18 @ocean90
8 years ago

In 38691:

Embeds: Add support for embedding Facebook photos of a user/page.

See #34737.

#19 @josephvb10
8 years ago

For some reason with this Facebook oEmbed is being returned in arabic language. Could this be a problem in Facebook's end (maybe by misidentifying the server's IP)?

#20 @miraclemaker
8 years ago

There's an issue with Facebook single post embeds.

The following url should embed a single post from the Wordpress account on Facebook:

What I'm actually getting on 4.6.1 is a feed of *all* posts from that account.
You can see the correct behaviour here:

#21 @swissspidy
8 years ago

@miraclemaker This change here is for WordPress 4.7, not 4.6.1. In 4.6.1, auto-discovery will kick in. There, Facebook provides the embed code you're seeing now. So that's expected. If you use the latest nightly build, everything works fine.

#22 @miraclemaker
8 years ago

@swissspidy Got it, thanks for taking the time to clear that up.

#23 @pareshradadiya
8 years ago

$wp_embed->autoembed( $content ) doesn't appears to be working for the Facebook embed

#24 @swissspidy
8 years ago

@pareshradadiya Sounds unlikely. Perhaps no connection could be made to their servers or something. Could you share some code to reproduce it?

#25 @pareshradadiya
8 years ago


Add these two links in your post content from the admin dashboard

Try to access this post from frontend, you will see the embed for youtube video but not for the facebook video

#26 @swissspidy
8 years ago

@pareshradadiya Embedding the video by pasting the URL works for me. Screenshot:

#27 @pareshradadiya
8 years ago


Embedding the video by pasting the URL does not works for me.

Here is a screenshot for reference!

#28 @swissspidy
8 years ago

@pareshradadiya That second video works well on my install as well. Which version of WordPress are you using? Do you see any errors in the browser's developer console? What meta data is stored for this post in the database?

#29 @mattla93
5 years ago

  • Keywords needs-testing added; has-patch needs-refresh removed
  • Type changed from enhancement to defect (bug)
  • Version set to 5.2

Does anyone has problems with the facebook oembed api? When calling the API from local browser we've no issues, but calling from php and the wordpress causes timeouts on the facebook-api or "unsupported browser" issues.

the ajax-call always returns

{"success":false,"data":{"type":"not-embeddable","message":"<code>https:\/\/\/burgerphilipp\/posts\/2231509943565310<\/code> konnte nicht eingebunden werden."}}

#30 @swissspidy
5 years ago

  • Keywords has-patch added; needs-testing removed
  • Type changed from defect (bug) to enhancement
  • Version 5.2 deleted

@mattla93 Please do not change keywords on a 3-year old closed ticket to indicate that it's not working for you. If there's a reproducible issue with Facebook oEmbeds in WordPress, I recommend opening a new ticket for it with as much details as possible.

To me, it sounds like Facebook has done something on their end that breaks external access. For example, when I run wp eval "print_r( wp_remote_get( '' ) );" on a local site, I get timeouts as well. So this is not an issue with embeds specifically, but with Facebook blocking requests generally.

Note: See TracTickets for help on using tickets.