media_library_show_video_playlist
云策文档标注
概述
此文档介绍 media_library_show_video_playlist 过滤器,用于控制媒体库中“创建视频播放列表”按钮的显示或隐藏。默认情况下按钮始终显示,但可通过过滤器返回布尔值或 null 来调整行为。
关键要点
- 过滤器名称:media_library_show_video_playlist
- 参数:$show,布尔值或 null,决定是否显示按钮或基于媒体库中是否存在视频文件自动判断
- 默认值:从 WordPress 4.8.0 起为 true,之前版本为 null
- 性能考虑:返回 null 会触发查询以检查视频文件,这在大型媒体库中可能影响性能
- 相关函数:wp_enqueue_media() 用于加载媒体相关资源
代码示例
$show_video_playlist = apply_filters( 'media_library_show_video_playlist', true );注意事项
- 在 WordPress 4.8.0 之前,默认行为是返回 null,这会导致性能开销,建议在大型媒体库中避免使用
- 从 4.8.0 版本起,默认值改为 true,以优化性能并简化配置
原文内容
Allows showing or hiding the “Create Video Playlist” button in the media library.
Description
By default, the “Create Video Playlist” button will always be shown in the media library. If this filter returns null, a query will be run to determine whether the media library contains any video items. This was the default behavior prior to version 4.8.0, but this query is expensive for large media libraries.
Parameters
$showbool|null-
Whether to show the button, or
nullto decide based on whether any video files exist in the media library.
Source
$show_video_playlist = apply_filters( 'media_library_show_video_playlist', true );