wp_robots_max_image_preview_large()
云策文档标注
概述
wp_robots_max_image_preview_large() 是一个 WordPress 函数,用于在 robots 元标签中添加 max-image-preview:large 指令,允许搜索引擎显示大尺寸图片预览。
关键要点
- 函数作为 wp_robots 过滤器的回调使用,通过 add_filter('wp_robots', 'wp_robots_max_image_preview_large') 调用。
- 仅在博客设置为公开(blog_public 选项为真)时添加 max-image-preview:large 指令。
- 函数接收并返回一个关联数组 $robots,用于存储 robots 指令。
- 自 WordPress 5.7.0 版本引入。
代码示例
function wp_robots_max_image_preview_large( array $robots ) {
if ( get_option( 'blog_public' ) ) {
$robots['max-image-preview'] = 'large';
}
return $robots;
}
原文内容
Adds max-image-preview:large to the robots meta tag.
Description
This directive tells web robots that large image previews are allowed to be displayed, e.g. in search engines, unless the blog is marked as not being public.
Typical usage is as a ‘wp_robots’ callback:
add_filter( 'wp_robots', 'wp_robots_max_image_preview_large' );
Parameters
$robotsarrayrequired-
Associative array of robots directives.
Source
function wp_robots_max_image_preview_large( array $robots ) {
if ( get_option( 'blog_public' ) ) {
$robots['max-image-preview'] = 'large';
}
return $robots;
}
Changelog
| Version | Description |
|---|---|
| 5.7.0 | Introduced. |