钩子文档

rest_avatar_sizes

💡 云策文档标注

概述

rest_avatar_sizes 是一个 WordPress 过滤器,用于调整 REST API 中头像的像素尺寸数组。开发者可以通过此过滤器自定义返回的头像大小。

关键要点

  • 过滤器名称:rest_avatar_sizes
  • 用途:修改 rest_get_avatar_sizes 函数返回的头像尺寸数组
  • 参数:$sizes,一个整数数组,默认值为 [24, 48, 96]
  • 引入版本:WordPress 4.4.0

代码示例

add_filter( 'rest_avatar_sizes', function( $sizes ) {
    return [ 32, 64, 128 ];
} );

📄 原文内容

Filters the REST avatar sizes.

Description

Use this filter to adjust the array of sizes returned by the rest_get_avatar_sizes function.

Parameters

$sizesint[]
An array of int values that are the pixel sizes for avatars.
Default [ 24, 48, 96 ].

Source

return apply_filters( 'rest_avatar_sizes', array( 24, 48, 96 ) );

Changelog

Version Description
4.4.0 Introduced.