Codex tools: Log in / create account
Languages: English • 日本語 • (Add your language)
Contents |
Starting with WordPress 2.9, it's super easy to embed videos, images, and other content into your WordPress site.
All you need to do to embed something into a post or page is to post the URL to it into your content area. Make sure that the URL is on its own line and not hyperlinked (clickable when viewing the post).
For example:
Check out this cool video: http://www.youtube.com/watch?v=nTDNLUzjkpg That was a cool video.
WordPress will automatically turn that into a YouTube embed when the post is viewed. (Check the "Auto-embeds" check box in Administration > Settings > Media SubPanel.)
You can also opt to wrap the URL in the [embed] shortcode. It will accomplish the same effect, but does not require the URL to be on its own line and the "Auto-embeds" setting.
The easy embedding feature is mostly powered by oEmbed, 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 was designed to avoid having to copy and paste HTML from the site hosting the media you wish to embed. It supports videos, images, text, and more.
Not by default, no. WordPress will only embed URLs matching an internal whitelist. This is for security purposes.
You can use all of these:
Adding support for an additional website depends on whether the site supports oEmbed or not.
If a site supports oEmbed, you'll want to call wp_oembed_add_provider() to add the site and URL format to the internal whitelist.
You'll need to register a handler using wp_embed_register_handler() and provide a callback function that generates the HTML.
The oEmbed implementation in WordPress has discovery disabled. By default, you can only embed from websites that are listed on the internal whitelist. This is to prevent accidental embedding from malicious websites.
However if you feel you are knowledgeable enough to avoid this, you can give unfiltered_html users (Administrators and Editors) the ability to embed from websites that have oEmbed discovery tags in their <head>. You merely need to install Enable oEmbed Discovery plugin.