Languages: English • Hrvatski • Italiano • 日本語 Nederlands • Português do Brasil • Русский • 中文(简体) • 中文(繁體) • (Add your language)
从 WordPress 2.9 开始,向您的 WordPress 站点嵌入视频、图像等多媒体内容变得十分简单。
要嵌入内容,您要做的就是将内容的 URL 直接粘贴至您的文章或页面编辑框中。请确保 URL 独立成行。请不要设置超级链接。
文章内容举例:
我发现这个视频很酷: http://www.youtube.com/watch?v=nTDNLUzjkpg 快去看看吧。WordPress 将自动把链接转换成 YouTube 指定的嵌入代码。 (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 to be enabled. It also allows you to set a maximum (but not fixed) width and height, like so: [embed width="123" height="456"]...[/embed]
如果WordPress把您嵌入的视频没有成功解析,则会返回一个带超链接的URL地址。
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.