- Home
- About
- Archives
- My WordPress Plugins
- Bulk Change Attachment Parent
- Clean Archives Reloaded
- Disable Trackbacks
- jQuery Lightbox For Native Galleries
- Local Time
- Regenerate Thumbnails
- Registered Users Only
- SyntaxHighlighter Evolved
- Viper’s Video Quicktags
- WordPress Admin Bar
- WordPress Download Counter
- WordPress.org One-Click Install
- YOURLS: Short URL Widget
- Other Plugins
- Discontinued Plugins
- Donate
- Contact
Easy Embeds For WordPress 2.9
This post needs updating — some things have changed since it was initially written. The Codex article is more up to date.
I’ve been working on some code for WordPress 2.9 for a while now that is designed to make embedding remote content (namely videos) into your blog a lot easier. Today the code went into the WordPress core.
If you’re into testing alpha code and would like to try it out, just checkout a copy of the WordPress trunk via SVN. You can also just wait until later this month for when the more stable WordPress 2.9 beta is planned to be released.
Using The Feature
Once you’re running the code, you’ll first want to visit Settings -> Media and check out the new “Embeds” section. The default options will work perfectly fine, but you can tweak them if you wish.

To embed something, such as a video, you have two options:
- Paste a plain-text (i.e. not hyperlinked with a
<a>tag) URL on it’s own line (that’s important) somewhere within your post. Obviously this will not work for all URLs, but more on that in a moment. - Wrap your URL in the new
[embed]shortcode. (there’s a UI for this — click the “Add Video” icon and then “From URL”)
In order for the URL to actually turn into an embed, one of three conditions needs to be true:
- An internal handler has been supplied by the WordPress core or a plugin.
- The site hosting the external content supports the oEmbed API and the URL to the site’s provider service is know by WordPress, either via the predefined list or added by a plugin.
- There is an oEmbed discovery
<link>tag in the<head>of the entered URL which contains the URL to the site’s oEmbed provider. This option is only available to authors with theunfiltered_htmlcapability.
If all goes well, then it’ll embed like this:
Note that no plugins were used in the above embed and the HTML was pulled directly off of Vimeo’s servers. All I did was paste this on to it’s own line: http://www.vimeo.com/240975 WordPress connected to the URL, found the discovery tag in the <head>, and used it to get the HTML back from Vimeo’s servers. It’s then cached to the post meta to avoid slow page loads (editing a post clears the cache).
Another example is Flickr. Just paste the URL to the image’s page (the page where people can leave comments, etc.) into your post. For example, here’s a picture by Donncha: http://www.flickr.com/photos/donncha/4008546362/

Default Supported Sites
The following sites are supported out of the box for all users — you can easily add more via plugins (see below) and admins can use other sites that use the oEmbed discovery tag.
- YouTube (via oEmbed)
- Blip.tv (via oEmbed)
- Flickr images and videos (via oEmbed)
- Hulu (via oEmbed)
- Viddler (via oEmbed)
- Qik.com (via oEmbed) — never heard of this site, but it was listed on oEmbed’s website, so…
- Revision3 (via oEmbed)
- Google Video (via an internal handler)
- PollDaddy (via an internal handler)
- DailyMotion (via an internal handler)
Using Plugins To Add Support For More Media Types/Sites
This feature can be used to embed literally any type of content from any website that supports embedding it’s content. If the site supports oEmbed and has a discovery tag to their oEmbed provider URL in the <head> of their pages, then you’re good to go — you can embed their content without doing anything extra.
However if they don’t have an oEmbed discovery tag or don’t support oEmbed period, then you’ll need to use/write a plugin to tell WordPress about the site. You may also want to do this for sites that support oEmbed and has a discovery tag, but that WordPress doesn’t specifically know about. The reason for this is that oEmbed discovery is disabled for non-administrators for security purposes (otherwise those users would be able to import arbitrary HTML via the oEmbed protocol).
Registering new URL formats with WordPress is relatively easy and there are two methods for doing so:
Adding Support For A Site That Supports oEmbed
If the site is cool enough to support oEmbed, then it’s dead simple. All you have to do is tell WordPress the URL format to match and what the URL to the site’s oEmbed provider is:
wp_oembed_add_provider( 'http://site.com/watchvideo/*', 'http://site.com/oembedprovider' );
Note the underscore after “add”. This was not there when this post was originally written — the function name was changed before WordPress 2.9′s release.
The first parameter is the format of the content URLs with asterisks used as wildcards. For YouTube for example, it could be http://*.youtube.com/watch*. The second parameter is the base URL of oEmbed provider. You can use {format} if the format (JSON or XML) is explicitly a part of the URL rather than just a query variable (which will be added automatically). This is however somewhat rare and most sites use the same provider URL for both JSON and XML requests.
Adding Support For A Site That Does NOT Support oEmbed
This is more complicated, but still rather easy. You’ll need to register the URL format that you want to match and then define the callback function that will be returning the content (usually some embed HTML).
For example, here’s the handler for Google Video that’s built into WordPress:
/**
* The Google Video embed handler callback. Google Video does not support oEmbed.
*
* @see WP_Embed::register_handler()
* @see WP_Embed::shortcode()
*
* @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.
* @param array $attr Embed attributes.
* @param string $url The original URL that was matched by the regex.
* @param array $rawattr The original unmodified attributes.
* @return string The embed HTML.
*/
function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) {
// If the user supplied a fixed width AND height, use it
if ( !empty($rawattr['width']) &amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp; !empty($rawattr['height']) ) {
$width = (int) $rawattr['width'];
$height = (int) $rawattr['height'];
} else {
list( $width, $height ) = wp_expand_dimensions( 425, 344, $attr['width'], $attr['height'] );
}
return apply_filters( 'embed_googlevideo', '&amp;amp;amp;amp;amp;lt;embed type=&amp;amp;amp;amp;amp;quot;application/x-shockwave-flash&amp;amp;amp;amp;amp;quot; src=&amp;amp;amp;amp;amp;quot;http://video.google.com/googleplayer.swf?docid=' . esc_attr($matches[2]) . '&amp;amp;amp;amp;amp;amp;amp;hl=en&amp;amp;amp;amp;amp;amp;amp;fs=true&amp;amp;amp;amp;amp;quot; style=&amp;amp;amp;amp;amp;quot;width:' . esc_attr($width) . 'px;height:' . esc_attr($height) . 'px&amp;amp;amp;amp;amp;quot; allowFullScreen=&amp;amp;amp;amp;amp;quot;true&amp;amp;amp;amp;amp;quot; allowScriptAccess=&amp;amp;amp;amp;amp;quot;always&amp;amp;amp;amp;amp;quot;&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;/embed&amp;amp;amp;amp;amp;gt;', $matches, $attr, $url, $rawattr );
}
wp_embed_register_handler( 'googlevideo', '#http://video\.google\.([A-Za-z.]{2,5})/videoplay\?docid=([\d-]+)(.*?)#i', 'wp_embed_handler_googlevideo' );
The last line is the important one as registers the new handler. Here’s the parameters:
- The handler ID. This is just used to identify it internally and if you need to unregister it later. It needs to unique, but other than that, it doesn’t matter what it is.
- The regex that should be used to check a URL to see if it should be handled by this handler.
- The callback function name.
The callback function will receive 4 parameters (as described in the phpdocs in the above example). Which your function uses is entirely up to you. The function should return the resulting content or HTML, or false to abort handling the URL and to let other handlers potentially handle it.
wp_expand_dimensions() is a new function that will return the largest dimensions possible given an example width and height (to determine the ratio) and the maximum overall dimensions. For example, what’s the biggest we can make a 400×300 pixel video without going over 600×600 pixels?
list( $width, $height ) = wp_expand_dimensions( 400, 300, 600, 600 ); echo $width; // 600 echo $height; // 450
If you have any questions or feedback about this new feature, feel free to leave them via the comments form below.
Update 5:39 PST: Added list of default sites handled by WordPress that all users can use.
Tweet| Print article | This entry was posted by Alex (Viper007Bond) on October 13th, 2009 at 3:04 PM, and is filed under WordPress. Follow any responses to this post through RSS 2.0. You can leave a response or pingback from your own site. |
- Embedding video in WordPress will get easier, thanks to Portland’s Viper007Bond « Silicon Florist
- Starting a Blog — Multimedia Content Plugins – Brent Logan
- WordPress 2.9 ? oEmbed | ?????
- Noch einfacher Videos & Bilder einbinden mit oEmbed in WordPress 2.9 – zu dt “automatische Erkundung”, Zu WordPress 29 Nightly-Builds, Weitere Informationen zu diesem Thema, Offizielle Seite von oEmbed, Technische Details zu oEmbed auf Deutsch, WordPr
- oEmbeds And Post Thumbnails « Weblog Tools Collection
- WordPress 2.9 Features – WordPress Tavern Forum
- WordPress 2.9 Features
- WordPress 2.9 Features List | TheTechJournal.com
- WordPress 2.9 just around the corner – Alex Leonard’s Blog
- Web Design Blog » Wordpress Blog 2.9 Features – Designbit – Blog Design, Web Design, Wordpress and Shopify Blog
- Wordpres 2.9 nuevas funciones | Denken Über
- Worpdress 2.9 nuevas funcionalidades « RSS2Blogs
- Wordpress 2.9 – Features, Tips and Screenshots (Updated)
- The Audi S(F)4 | The Woodwork
- WordPress Picks for the week [10/25] | Techtites
- WordPress 2.9 ?????? | detlog.org
- OohEmbed Plugin Test – Brent Logan
- Funktioner i kommande 2.9 | WP-Support Sverige
- Mobypicture announces oEmbed support – Mathys van Abbe
- WordPress 2.9 a chystané novinky (2): Jednoduché vkládání médií z externích služeb (nap?. YouTube) do p?ísp?vk? prost?ednictvím oEmbed | Separatista
- WordCast 75: WordPress 2.9 and Beyond | WordCast – The #1 WordPress Podcast, with WordPress News, WordPress Tips, WordPress Plugins, WordPress Themes, Blogging News, Blogging Tips, and more! | Bitwire Media
- WordPress 2.9 på norsk « neppe.no
- WordPress 2.9: The Bloggers Gift for the Holidays | WordCast – The #1 WordPress Podcast, with WordPress News, WordPress Tips, WordPress Plugins, WordPress Themes, Blogging News, Blogging Tips, and more! | Bitwire Media
- Reflections » WordPress 2.9 Enhancements Every Developer Must Know
- WordPress 2.9: The Bloggers Gift for the Holidays | WordCast – Blogging news, WordPress help, WordPress plugins, WordPress themes, WordPress news
- WordCast 75: WordPress 2.9 and Beyond | WordCast – Blogging news, WordPress help, WordPress plugins, WordPress themes, WordPress news
- Learning oEmbed
- Per oEmbed Videos und Bilder in Wordpress einbinden » F!XMBR

about 10 months ago
This is huge!
>An internal handler has been supplied by the WordPress core
Can we get the list (in your blog post) of the ones with internal handlers?
> The site hosting the external content supports the oEmbed API and the URL to the
> site’s provider service is know by WordPress, either via the predefined list
Can we get the list of this as well for testing? Also how is additions nominated?
Thank you.
about 10 months ago
Lloyd Budd on October 13th, 2009 at 4:10 PM2009-10-13T23:10:40ZF jS, Y \a\t g:i A wrote:
Oh, good thinking.
Lloyd Budd on October 13th, 2009 at 4:10 PM2009-10-13T23:10:40ZF jS, Y \a\t g:i A wrote:
Sure. I basically added all of the ones listed on the oEmbed website:
(and apparently I’ve
foundfixed anencodingbug inSyntaxHighlighterone of the old plugins I use)$this->providers = apply_filters( 'oembed_providers', array( 'http://*.youtube.com/watch*' => 'http://www.youtube.com/oembed', 'http://youtube.com/watch*' => 'http://www.youtube.com/oembed', 'http://blip.tv/file/*' => 'http://blip.tv/oembed/', 'http://*.flickr.com/*' => 'http://www.flickr.com/services/oembed/', 'http://www.hulu.com/watch/*' => 'http://www.hulu.com/api/oembed.{format}', 'http://*.viddler.com/*' => 'http://lab.viddler.com/services/oembed/', 'http://qik.com/*' => 'http://qik.com/api/oembed.{format}', 'http://*.revision3.com/*' => 'http://revision3.com/api/oembed/', // Vimeo uses the discovery <link>, so leave this commented to use it as a discovery test //'http://www.vimeo.com/*' => 'http://www.vimeo.com/api/oembed.{format}', ) );Sites added to this list should be trusted to not use malicious HTML (as all users on the blog, even those without
unfiltered_htmlcapabilities, can embed content from these sites) and should probably be considered popular (as we can’t include every site under the sun). Plugins can add additional providers as well as non-oEmbed handlers.about 10 months ago
Wow!! This seems to be really exiting. Will test it and let you know if I face any issues. Thanks!
about 10 months ago
I am very excited!…and congrats for getting your code into core!
about 10 months ago
It’s working great. This and the image editing tools and thumbnail system are awesome additions to core.
about 10 months ago
Awesome. Tried it on my test site, works brilliantly. Super duper thumbs up.
This is just the sort of thing needed in core. Totally eliminates the need for a whole swath of plugins.
about 10 months ago
Hi
While it supports Flickr, why not support Picasaweb too! (since I use it extensively)
S.K
about 10 months ago
S.K on October 16th, 2009 at 11:17 PM2009-10-17T06:17:35ZF jS, Y \a\t g:i A wrote:
That’s the whole point of this — it’s an API rather than adding support for only specific sites. Flickr is supported and used in my post as an example because they support oEmbed, which makes it stupidly easy to embed their images into posts.
Sites that don’t support oEmbed can be added one-by-one using a plugin and my API.
about 10 months ago
Does the Flickr embed implementation give the correct attribution information, or would that have to be added manually?
about 10 months ago
P.S. The comment system got my browser wrong, it’s Chrome
about 10 months ago
Mike on October 17th, 2009 at 4:01 PM2009-10-17T23:01:03ZF jS, Y \a\t g:i A wrote:
http://www.flickr.com/services/oembed?url=http%3A//www.flickr.com/photos/donncha/4008546362/
Mike on October 17th, 2009 at 4:02 PM2009-10-17T23:02:06ZF jS, Y \a\t g:i A wrote:
To be fair, the plugin is a few years old and Chrome uses Webkit (Safari).
about 10 months ago
Great. Thanks for answering. Like the iPhone theme
about 10 months ago
Is there likely to be a player included for flash videos from your own doamin other than JWPlayer. JWPlayer is great, but isn’t free for any kind of commercial use, including blogs that just have a little advertising.
I know WordPress have their own player, but it is heavily branded and aimed for use with WP.com or Videopress
about 10 months ago
Hello, I have been using your plugin for a long time and it is a great piece of code, I have modified it to support a couple extra video providers that I needed, but I don’t see them mentioned here, so I would be more than glad to share the code, just contact me and let me know to get it to you.
about 10 months ago
Andy Beard on October 19th, 2009 at 5:44 AM2009-10-19T12:44:31ZF jS, Y \a\t g:i A wrote:
Embedding of FLV will not be supported out of the box, nor would it be possible for JWPlayer to be bundled with WordPress due to it’s license.
about 10 months ago
iamzaks on October 19th, 2009 at 6:48 AM2009-10-19T13:48:54ZF jS, Y \a\t g:i A wrote:
Unless the video sites are very popular, support for them should be added via a plugin that uses this new API.
about 10 months ago
This is awesome! I’ve already converted all my embeds over to the new format.
I would love the ability to embed Amazon product thumbnails instead of having to use the associate widgets that Amazon offers. (The oohEmbed.com site suggests this is possible.) See my books page for an example:
http://blogan.net/blog/im-reading/
Also, is there any way to enable CSS styling? In other words, how could I apply float:left to the embeds?
Thanks for all your work in this!
about 10 months ago
Brent Logan on October 20th, 2009 at 8:42 AM2009-10-20T15:42:36ZF jS, Y \a\t g:i A wrote:
oohEmbed.com is an oEmbed proxy basically. They provide oEmbed support for sites that don’t support it themselves.
It’d be VERY easy to add Amazon support — just write a plugin that uses the new
wp_oembed_addprovider()function.about 10 months ago
Viper007Bond on October 20th, 2009 at 11:09 AM2009-10-20T18:09:06ZF jS, Y \a\t g:i A wrote:
This is clearly a case where “ease” is in the eye of the beholder.
about 10 months ago
Brent Logan on October 20th, 2009 at 11:23 AM2009-10-20T18:23:28ZF jS, Y \a\t g:i A wrote:
http://viper007bond.pastebin.com/f4bf64b8d
about 10 months ago
Thanks! Now I’m having problems (no good deed goes unpunished…).
I downloaded your sample plugin file, saved it with a php extension, and uploaded it to my plugins folder. When I attempted to activate it, I got the following error message:
I’m running the latest version of WP (SVN 12078) and embedding of YouTube videos is working fine using [embed].
Should I be able to find wp_oembed_addprovider() in wp-includes/class-oembed.php?
about 10 months ago
//Fatal error: Call to undefined function wp_oembed_addprovider()//
A dumb question: should it be capitalized like: “wp_oEmbed_addprovider()”?
S.K
about 10 months ago
Brent Logan on October 20th, 2009 at 10:58 PM2009-10-21T05:58:08ZF jS, Y \a\t g:i A wrote:
I guess I’m doing it too early. Try this: (also untested)
http://viper007bond.pastebin.com/f2451e9b7
about 10 months ago
S.K on October 20th, 2009 at 11:08 PM2009-10-21T06:08:42ZF jS, Y \a\t g:i A wrote:
PHP function names are case insensitive, plus it’s defined as all lowercase.
about 10 months ago
Viper007Bond on October 21st, 2009 at 2:06 AM2009-10-21T09:06:10ZF jS, Y \a\t g:i A wrote:
Ouch! That plugin turned my blog into a blank screen. A nice, simple white theme with no distracting text.
Maybe I should wait…?
about 10 months ago
The blank screen may be a side effect of oohEmbed.com. Clicking on the Amazon product example results in a *long* wait, while the other examples immediately provide JSON files.
about 10 months ago
Alright, I guess I’ll actually test the code I write. *sigh* lol
about 10 months ago
I’m an idiot. I forgot that Ryan renamed the function before committing it. There’s an extra underscore: wp_oembed_add_provider()
Try this code: http://viper007bond.pastebin.com/f5792e470
about 10 months ago
Erm, seems oohEmbed.com’s Amazon code is broken. It 404′s for Amazon requests.
about 10 months ago
And until today, wp_oembed_add_provider() didn’t support regex for the first parameter. If you set the new third parameter to
true, then it’ll know the first parameter is regex instead of just asterisks for wildcards.about 10 months ago
An example of how to add additional oEmbed providers: http://wordpress.org/extend/plugins/oohembed/
about 10 months ago
Viper007Bond on October 25th, 2009 at 10:05 PM2009-10-26T05:05:33ZF jS, Y \a\t g:i A wrote:
I tried installing and using it.
Hmm. I didn’t expect the Amazon link to work. I did expect the xkcd link to. Neither did. Youtube embeds are working for me.
I am running WP 2.9-rare (latest SVN as of today).
But then again, I appear to be somewhat special. I can’t even get the quote function to work here. It shows my entire comment as a quote, even though only your quote is within the quote “quick codes.”
about 10 months ago
Brent Logan on October 25th, 2009 at 11:08 PM2009-10-26T06:08:15ZF jS, Y \a\t g:i A wrote:
Both Amazon and XKCD are broken on oohEmbed. This shouldn’t be 404: http://oohembed.com/oohembed/?url=http%3A//xkcd.com/310/
YouTube is handled natively by WordPress 2.9 (YouTube recently added oEmbed support).
about 10 months ago
There should be backwards compatibility for the numerous plugins that use shortcodes such as: [youtube] [/youtube]. Otherwise, if you want to use the native oEmbed features you’ll need to go back and re-edit a ton of posts.
about 10 months ago
Bryan on October 26th, 2009 at 8:43 PM2009-10-27T03:43:17ZF jS, Y \a\t g:i A wrote:
It’s up to the plugin authors to provide that functionality.
Or if they don’t, they’ll work fine side by side with this new code.
about 10 months ago
I had no idea wordpress 2.9 was available yet. Thanks for all the tips and thanks to all fo teh commenters as well…..
about 10 months ago
Mike on October 30th, 2009 at 11:05 AM2009-10-30T18:05:40ZF jS, Y \a\t g:i A wrote:
It’s not available yet — it’s still in alpha.
about 10 months ago
oohEmbed maintainer here. I noticed a couple of comments that oohEmbed support for Amazon & xkcd is broken. I think it was a temporary thing since both sites are working right now.
I really appreciate the work you are doing in getting oEmbed support into WP! If you find any issues in future with oohEmbed, please file a bug report: http://code.google.com/p/oohembed/issues/list
about 10 months ago
I have a test page on my blog for virtually all the embeds currently supported by the oohEmbed plugin. I’m still having problems with:
amazon.com
twitpic.com
xkcd.com
yfrog.com
All except amazon.com appear to be working on the oohEmbed site.
about 9 months ago
How hard would it be for a site owner to add this ability? Our system hosts an MU site for our teachers and 99% of the content is ours. Our upgrade to 2.8 has been a little painful due to our old video plugin no longer working properly so we’ve switched to your plugin but we have a lot of links that need updating.
about 9 months ago
My plugin will continue working into 2.9 (it works side by side with this new code).
However to support using the new API, you’d want to use code based on the big block above under “Adding Support For A Site That Does NOT Support oEmbed”. Just use regex that matches *.flv or whatever.
about 9 months ago
Backwards compatibility/future support is part of the reason I settled on your plugin. But anything that makes it even slightly easier for the teachers is good.
about 9 months ago
Gonna sound like a strange question, but the code on my site dictates that our OEmbed discovery links are not in the head of the document, as is recommended in the spec. I know most places don’t seem to limit their grep of the page to the head, but wanted to know if you knew off hand how you guys were doing it, as I only added it in to work with WordPress.
Thanks!
about 9 months ago
In Reply To Scott:
Yes, for performance reasons WordPress only looks before the
</head>tag (the less HTML to search the better). If your<link>tag is outside the head, then WordPress won’t find it, not to mention I think you’ll break your site’s validation.about 8 months ago
This is really cool and handy with the oembed support. Great work!
I was just wondering with the [embed] shortcodes, is it possible to send arguments to the oembed discovery? Like for instance being able to pass some of Vimeos arguments for oembed to custom the embed a bit more? http://www.vimeo.com/api/docs/oembed
Cheers!
about 8 months ago
In Reply To Johan Steen:
Ooo, I didn’t know they supported that!
No though, however my Viper’s Video Quicktags plugin will be doing exactly that, as well as things that aren’t supported. For example YouTube’s oEmbed provider doesn’t allow you to control the colors as far as I’m aware, but my plugin will regex in the parameters.
about 8 months ago
works like a charm! great work!
about 8 months ago
works like a charm! great work! this site has a much greater list of services that use oembed: http://oohembed.com/ perhaps all those should be added to core
about 8 months ago
iamzaks on December 18th, 2009 at 8:05 AM2009-12-18T16:05:14ZF jS, Y \a\t g:i A wrote:
Not a good idea relying on a third party of unknown trust. It’s safe to assume that YouTube won’t start giving out malicious HTML, but it’s impossible to know with oohEmbed.
However plugins always come to the rescue.
http://wordpress.org/extend/plugins/oohembed/
about 8 months ago
Can swfobject be used with ooembed?
As the generated html provided by youtube et al is not that correct standards-wise…
about 8 months ago
Apokalupsis on December 18th, 2009 at 11:45 PM2009-12-19T07:45:22ZF jS, Y \a\t g:i A wrote:
Nope, however a plugin could register a handler and return some HTML to use instead of oEmbed. wp_embed_register_handler() would be the function to use.
about 8 months ago
Great feature but I wonder why the white list of video hosting sites has not been made editable with a configuration panel (without touch the code). For me looks a little bit of wall-gardening the users specially now that WP2.9 rolled out. My2c.
about 8 months ago
Can it be used in widgets, with the same ease as using the [embed] shortcode?
Thanks
S.K
about 8 months ago
In Reply To S.K:
Mmm, no it cannot.
I think that’s patch worthy though. I’ll submit one for inclusion in a future release.
about 8 months ago
I noticed on the trac, you briefly mentioned that YouTube isn’t using the Oembed service. Are they now? I am looking at modifying the output to make XHTML Strict. Does class-oembed.php do the main job or are there any other files I should know of?
about 8 months ago
In Reply To Viper007Bond:
Thanks so much for your response.
S.K
about 8 months ago
Darran on December 19th, 2009 at 6:21 PM2009-12-20T02:21:00ZF jS, Y \a\t g:i A wrote:
Yes, YouTube is oEmbed enabled, complete with discovery tags. They rock.
If you want to modify the returned HTML, the filter to use is
oembed_dataparse. Look at thestrip_scribd_newlines()function inside ofclass-oembed.phpfor an idea of how to go about doing it (look at$urlto see if it’s YouTube, then modify$htmland return it).Note that this will modify the result from YouTube’s servers and before it goes into the cache (stored in the post meta). This means it won’t affect existing embeds unless you edit and save the post (this flushes that post’s cache). The
embed_oembed_htmlfilter could be used instead (runs between the cache and insertion into the post), but that’d mean more regex on every page load. Better to do it on it’s way into the cache.about 8 months ago
Could you please tell me how to change the size of the image embedded from Flickr? I tried adding maxwidth and maxheight but no joy.
S.K
about 8 months ago
Ok. I got the tips from Dougal Campbells’ blog on sizing the images.
But why this labour – I can get the link to the actual size and use it. This oembed is not of much use to images, but ideal for videos.
S.K
about 8 months ago
In Reply To S.K:
WordPress uses the HTML that Flickr gives it.
Plus I’d personally have an image that fit my theme and/or the settings I select instead of an arbitrary size.
about 8 months ago
Awesome work!
How can one pull video thumbnails via oEmbed? Looked trough the code but couldn’t figure it out
I’d use Vimeo for most of ‘em and maybe youtube a few times.
about 8 months ago
In Reply To Stef:
Depends on the provider. Some supply the URL to the thumbnail, some don’t.
YouTube doesn’t supply them, but their thumbnail URLs is predictable: http://img.youtube.com/vi/nTDNLUzjkpg/0.jpg
Vimeo supplies them.
WordPress doesn’t use them though. It just directly embeds.
about 8 months ago
Fantastic feature! I’ve been waiting for something like this for ages.
It works beautifully but I’m coming up with errors in the code and wonder if I’m alone there or if there’s something I can change or if I should just leave it alone and WP will fix it in a release?
Link to post generating errors:
http://foreverdyingbrightly.com/blog/2009/12/welcome-to-alienpredator-hell-a-wholly-owned-subsidiary-of-weyland-yutani-inc/
about 8 months ago
This oEmbed is a huge and fantastic update. I am using it in my main blog.
But I have a weird Bug with some YouTube and Dailymotion videos.
My settings in “Media” are set to: Width: 624 Height: 0
Every video should be resized to width= 624px, this sometimes happens but other times it resizes to width=”384″ (maybe a default from youtube).
For Example:
This video (with URL http://www.youtube.com/watch?v=CeTa7YYkMcE ) doesn’t resize to my personalized width… but to 384, here is the post:
http://www.aeromental.net/2009/12/25/video-of-the-pope-benedict-xvi-being-attacked-by-a-woman-during-christmas-eve-celebration/
But in other posts the width attribute works perfect:
http://www.aeromental.net/2009/12/29/walking-with-dinosaurs-the-live-experience-triceratops-versus-tyrannosaurus/
How can I fix this?
about 8 months ago
Hi
I embedded a Dailymotion video by this method. But additional metadata gets added below the video like this:
“Bianca Castafiore : Animation. Uploaded by quiestce88. — Independent web videos”.
A reader can always get this kind of info from the video page on clicking the “menu” icon. I want to avoid display of such details underneath the video.
Could you please guide me how to do this.
Thanks.
S.K
about 8 months ago
In Reply To S.K:
If you wish to modify the HTML supplied by DailyMotion, I’d recommend using the
oembed_dataparsefilter.about 8 months ago
Hi
This is the extra line that is added by Dailymotion beyond the “embed” and “object” enclosure (just before the closing of the “div”) as found in the oEmbed response:
Could you please tell me how to remove rendering of such extra HTML line.
Thanks
S.K
about 8 months ago
In Reply To S.K:
Yes, I’m aware of the line. It is being added by DailyMotion, not by WordPress. If you wish to remove it, you’ll need to use or write a little plugin that filters the HTML that DailyMotion provides.
about 8 months ago
Hi, I updated one of my blogs to WP 2.9 but can´t see this feature anywhere. In Settings > Media I don’t have the option for embed like you show it in the first screen shot. I updated the system twice (1st time automatically and 2nd time manually) and no changes.
Any idea what could be the problem? Thanks for your help!
about 8 months ago
In Reply To Mandy:
Look at the bottom-right of your admin area. You’ll find your blog is still running WordPress 2.8.6.
about 8 months ago
I was talking about a different blog, it’s not online yet. and I checked in the sourcecode – there it says wp 2.9.
about 8 months ago
I post the Youtube width bug again, but showing the responses given from youtube:
Lets consider maxwidth: 620 and maxheight: 700
Bug: (width changes to 384)
http://www.youtube.com/oembed?format=xml&maxwidth=620&maxheight=700&url=http:%2f%2fwww.youtube.com%2fwatch?v=CeTa7YYkMcE
Correct width:
http://www.youtube.com/oembed?format=xml&maxwidth=620&maxheight=700&url=http:%2f%2fwww.youtube.com%2fwatch?v=H5UmoD9ReXU
Is there a fix to this?
PD.- None of the Dailymotion videos obey the width parameter.
about 8 months ago
In Reply To DanielSemper:
I don’t have any control over YouTube, however my guess is that YouTube won’t return an embed size that’s larger than the original video’s size. But that’s only a guess.
about 7 months ago
In Reply To Viper007Bond:
Now that WordPress has built in capabilities to embed videos, and to also show post thumbnails, is it possible to combine the two?
I.e so that the post thumbnail can automatically become the first embedded video’s image?
about 7 months ago
In Reply To Mandy:
Hi,
same problem with me: Updates to WP 2.9, the Feature in Settings -> Media is not shown. Any ideas ?
regards
Frank
about 7 months ago
Hi Viper007Bond?
Thanks for the work, it is great to have this feature in wordpress 2.9.
Just a question, I wonder if there is a way to center the image, instead of floating left?
Also, I tried to use the {embed] code to resize the image. It only works to reduce size but not when I want to have a large size (>500px). I wonder if is a way for this ?
Thanks for your help
about 7 months ago
In Reply To Shirls:
This should do the trick:
As for the size, it’s somewhat up to the remote site, but the max width and max height parameters as set at Settings -> Media are passed along to the remote site. Flickr has preset image sizes and will return the largest preset size it has that fits within your dimensions for example.
about 7 months ago
In Reply To Viper007Bond:
Thanks for the codes. It works like magic !
As for the size, ummm….my wordpress media setting is set to 1024px. So it is flickr who presets it to max 500px. Well, nothing I can do.
Thanks for your help ! Really appreciate.
about 7 months ago
Has anyone created a handler yet for locally hosted .flv files in 2.9.1? Hoping to save myself a few minutes.
about 7 months ago
In Reply To Jeff Ivany:
Even though it’s recieving a recode currently, my plugin still works perfectly in WordPress 2.9.
http://www.viper007bond.com/wordpress-plugins/vipers-video-quicktags/
about 7 months ago
In Reply To Viper007Bond:
Yeah, I’ve considered your plugin but it does way more than what I’m looking for. I’ve been on a plugin purge recently, especially for anything that is now in the core. The only piece missing (for me) from the easy embeds functionality is embedding local .flv files.
about 6 months ago
Nice work but I also have the media size problem. The embed media size is not really responding to bigger values.
about 6 months ago
In Reply To Jonas:
Depends on the video site. WordPress gives them the max width and max height, but many opt to provide smaller videos. For example YouTube will not upscale videos to larger than their original size.
about 5 months ago
Hi Viper
First of all congrat to have joined the automatic team.. that’s a kick ass news
is there a way you would be aware of to have the youtube video displayed directly in 720?
thank you in advance
Steffy
about 5 months ago
In Reply To Steffy:
This feature uses the HTML that YouTube provides it.
However my Video Quicktags plugin can force HD by default and the upcoming v7.0 of it will make use of the WordPress 2.9 embeds feature.
about 5 months ago
Yeah installed your plugin and it totally rocks !!!
you are da man
Steffy
about 5 months ago
Hey Alex, you’ve got a strong grip of this Oembed stuff. I’m wondering if you know how to embed YouTube URL’s without related content using the Oembed feature in WordPress?
If you paste a URL into a WordPress post it will default to showing related content. Even if you add “&rel=0″ to the end of the URL it still shows related content when you hover over the video. Is there a way to alter the way WordPress uses Oembed for Youtube?
Thanks!
about 5 months ago
In Reply To Bill:
It’s 100% on YouTube’s oEmbed provider as it provides the HTML. It doesn’t have the ability to accept configuration arguments.
However, you’ll be happy to know that the next version of my Video Quicktags plugin will be built on top of the oEmbed feature. It will basically filter the results of the supported oEmbed results and expand upon them. With YouTube for example, it’ll get the HTML back from them, save the width/height (so you don’t get any black bars) and video ID, and then ditch the rest of it. It’ll then create XHTML valid embed code and append on some query strings based on your settings (colors, related content, etc. etc.). In short, same usage as now (URL-on-it’s-own-line) but much better results. It’s already in action on my blog for example (the plugin is still super-alpha though).
about 4 months ago
Thanks Alex, plugin looks perfect. I get what you’re saying about the Oembed feedback from YouTube not being able to manipulate the data. Thanks! Btw: love the little flags for the comments. Is this available as a plugin? Cheers
about 4 months ago
In Reply To Bill:
It’s a part of my theme, but it uses this library: http://firestats.cc/wiki/ip2c
about 3 months ago
I’m trying to build a little plugin to support local .flv files…
Your article is a great resource!
Unfortunately I’m unable to find a regular expression that can match the local uploaded flash files… I tried a lot but don’t knowing regex aven the online tutorial are like “old greek” for me.
I think the regex expression would trigger if it finds something like this:
[any text]
anyone can help?
Stefano