wp_get_video_extensions()
云策文档标注
概述
wp_get_video_extensions() 函数返回一个经过过滤的、WordPress 支持的视频格式列表。它通过 'wp_video_extensions' 过滤器允许开发者自定义支持的格式。
关键要点
- 函数返回一个字符串数组,默认包含 'mp4', 'm4v', 'webm', 'ogv', 'flv' 等格式。
- 使用 apply_filters('wp_video_extensions', $extensions) 钩子来过滤或修改支持的视频格式列表。
- 该函数自 WordPress 3.6.0 版本引入,常用于媒体处理、短码输出和模板渲染等场景。
代码示例
$video_extensions = wp_get_video_extensions();
print_r( $video_extensions );
原文内容
Returns a filtered list of supported video formats.
Source
function wp_get_video_extensions() {
/**
* Filters the list of supported video formats.
*
* @since 3.6.0
*
* @param string[] $extensions An array of supported video formats. Defaults are
* 'mp4', 'm4v', 'webm', 'ogv', 'flv'.
*/
return apply_filters( 'wp_video_extensions', array( 'mp4', 'm4v', 'webm', 'ogv', 'flv' ) );
}
Hooks
- apply_filters( ‘wp_video_extensions’, string[] $extensions )
-
Filters the list of supported video formats.
Changelog
| Version | Description |
|---|---|
| 3.6.0 | Introduced. |
Skip to note 2 content
Codex
Print an array of default WordPress-supported video extensions
Output:
Array ( [0] => mp4 [1] => m4v [2] => webm [3] => ogv [4] => wmv [5] => flv )