rest_get_avatar_sizes example

'description' => __( 'Type of the comment.' ),
                    'type'        => 'string',
                    'context'     => array( 'view', 'edit', 'embed' ),
                    'readonly'    => true,
                ),
            ),
        );

        if ( get_option( 'show_avatars' ) ) {
            $avatar_properties = array();

            $avatar_sizes = rest_get_avatar_sizes();

            foreach ( $avatar_sizes as $size ) {
                $avatar_properties[ $size ] = array(
                    /* translators: %d: Avatar image size in pixels. */
                    'description' => sprintf( __( 'Avatar URL with image size of %d pixels.' )$size ),
                    'type'        => 'string',
                    'format'      => 'uri',
                    'context'     => array( 'embed', 'view', 'edit' ),
                );
            }

            
'description' => __( 'Any extra capabilities assigned to the user.' ),
                    'type'        => 'object',
                    'context'     => array( 'edit' ),
                    'readonly'    => true,
                ),
            ),
        );

        if ( get_option( 'show_avatars' ) ) {
            $avatar_properties = array();

            $avatar_sizes = rest_get_avatar_sizes();

            foreach ( $avatar_sizes as $size ) {
                $avatar_properties[ $size ] = array(
                    /* translators: %d: Avatar image size in pixels. */
                    'description' => sprintf( __( 'Avatar URL with image size of %d pixels.' )$size ),
                    'type'        => 'string',
                    'format'      => 'uri',
                    'context'     => array( 'embed', 'view', 'edit' ),
                );
            }

            

function rest_get_avatar_urls( $id_or_email ) {
    $avatar_sizes = rest_get_avatar_sizes();

    $urls = array();
    foreach ( $avatar_sizes as $size ) {
        $urls[ $size ] = get_avatar_url( $id_or_email, array( 'size' => $size ) );
    }

    return $urls;
}

/** * Retrieves the pixel sizes for avatars. * * @since 4.7.0 * * @return int[] List of pixel sizes for avatars. Default `[ 24, 48, 96 ]`. */
Home | Imprint | This part of the site doesn't use cookies.