What Is oEmbed & How Does It Make Using WordPress Easier? [Technology Explained]

Ads by Google

wordpress logo oembed   What Is oEmbed & How Does It Make Using Wordpress Easier? [Technology Explained]If you have been using Facebook for any amount of time, you’ve probably noticed that when you post a link to a YouTube video, Facebook embeds the video into your update for you.  It also works on several other types of links such as MP3 files.  I post links to recordings sometimes and this comes in handy.

Ever since version 2.9, WordPress has given users the ability to link from several services (such as Flickr and YouTube) and have the content automatically embedded without you having to grab a bunch of code.  WordPress uses the oEmbed protocol to accomplish this.  You might be asking “so what is this oEmbed thing all about and how does it help a WordPress user like me?”

What Is oEmbed for WordPress?

oEmbed has been described several different ways.  The WordPress Codex describes it this way:

…a protocol for site A (such as your blog) to ask site B (such as YouTube) for the HTML needed to embed content (such as a video) from site B.

oEmbed’s homepage also gives a description:

oEmbed is a format for allowing an embedded representation of a URL on third party sites. The simple API allows a website to display embedded content (such as photos or videos) when a user posts a link to that resource, without having to parse the resource directly.

Ads by Google

So basically, oEmbed makes it possible for a webpage (ie. a WordPress site) to turn a link into embedded media simply by sending a request to the originator of the media content (such as YouTube or Flickr) for the embed code.

OK, so what does all that mean to me as a WordPress user?

How Does oEmbed Work With WordPress?

If you remember my example at the beginning about how Facebook handles YouTube links, you will know how YouTube links work in WordPress 2.9 and later.  You used to have to stop what you were doing, find the video to be embedded, and then find the embed code to paste into the HTML version of the post you were working on.

This process worked fine but now things are easier because of oEmbed.  Now, just grab the link.  There are two ways of using the link.  Allow me to demonstrate how it works using my own WordPress site.

  • Grab the link from the YouTube page.

oembed examplegrablink   What Is oEmbed & How Does It Make Using Wordpress Easier? [Technology Explained]

  • Paste the link on its own line.

oembed exampleinsertlinkownline   What Is oEmbed & How Does It Make Using Wordpress Easier? [Technology Explained]

  • This is what you’ll see.

oembed examplelinkownlinepreview   What Is oEmbed & How Does It Make Using Wordpress Easier? [Technology Explained]

  • Or you can use a short code and type something similar to this and have some flexibility with formatting:

oembed usingshortcode   What Is oEmbed & How Does It Make Using Wordpress Easier? [Technology Explained]

  • This example would look like this:

oembed exampleusingshortcode   What Is oEmbed & How Does It Make Using Wordpress Easier? [Technology Explained]

In basic terms that is what oEmbed is and how it works with WordPress.  WordPress does not allow use of just any old URL with oEmbed for security reasons.  There is a list of accepted sites on the WordPress Codex page about embeds.  It should also be mentioned that you can add more sites.  This process should be left for another article to cover.

WordPress seems to be on a never ending journey to make our lives easier.  This embedding ability is just another small example.   What WordPress feature do you like that makes your life easier?   Have you tried oEmbed?

Ads by Google

4 Comments - Write a Comment

Reply

Aibek

Hey Tim,

Thanks I had no idea baout this :-) I guess this is one of the disadvantages using the code view (in WordPress) all the time. When I need to add something I heading straight for the embed code.

timmyjohnboy

One of the many gems I came across tripping through the WordPress codex:)

Reply

Aibek

Hey Tim,

Thanks I had no idea baout this :-) I guess this is one of the disadvantages using the code view (in WordPress) all the time. When I need to add something I heading straight for the embed code.

Your comment