钩子文档

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.

  • width int|string
    Optional. The maxwidth value passed to the provider URL.
  • height int|string
    Optional. The maxheight value passed to the provider URL.
  • discover bool
    Optional. 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 );

Changelog

Version Description
4.9.0 The dnt (Do Not Track) query parameter was added to all oEmbed provider URLs.
2.9.0 Introduced.

User Contributed Notes