oembed_fetch_url
云策文档标注
概述
oembed_fetch_url 是一个 WordPress 过滤器,用于在获取 oEmbed 内容时修改提供商的 URL。它允许开发者自定义 oEmbed 请求的 URL,以调整嵌入行为或添加额外参数。
关键要点
- 过滤器名称:oembed_fetch_url
- 参数:$provider(oEmbed 提供商 URL)、$url(要嵌入内容的 URL)、$args(额外参数数组)
- 用途:在 WP_oEmbed::fetch() 中调用,用于连接 oEmbed 提供商并获取结果
- 版本历史:从 WordPress 2.9.0 引入,4.9.0 添加了 dnt(Do Not Track)查询参数
- 注意事项:oEmbed 结果会被缓存,修改后可能需要清除缓存才能立即生效
原文内容
Filters the oEmbed URL to be fetched.
Parameters
$providerstring-
URL of the oEmbed provider.
$urlstring-
URL of the content to be embedded.
$argsarray-
Additional arguments for retrieving embed HTML.
See wp_oembed_get() for accepted arguments. Default empty.More Arguments from wp_oembed_get( … $args )
Additional arguments for retrieving embed HTML. Default empty.
widthint|stringOptional. Themaxwidthvalue passed to the provider URL.heightint|stringOptional. Themaxheightvalue passed to the provider URL.discoverboolOptional. Determines whether to attempt to discover link tags at the given URL for an oEmbed provider when the provider URL is not found in the built-in providers list. Default true.
Source
$provider = apply_filters( 'oembed_fetch_url', $provider, $url, $args );
Skip to note 2 content
eclev91
WordPress actually caches the oembed results, so if you’re using this but not seeing it take effect immediately, try clearing those out like this: https://siteorigin.com/clearing-oembed-cache/