[Resolved] Avatar next to site title?

Home Forums Support [Resolved] Avatar next to site title?

Home Forums Support Avatar next to site title?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2311937
    Arp

    Would I need to create an element for this, or is there a hook/filter option?

    #2311972
    David
    Staff
    Customer Support

    Hi there,

    where is the Site Title being displayed ? Is it in the regular site header ? If you share a link to the site i can check, and advise which hook(s) to use.

    #2312017
    Arp

    It’s on a dev site (details in private info), and I currently have the avatar there as the logo, which I’d like to replace with the avatar so any change in avatar is reflected.

    It’s in the regular header, where the nav is being used as the header.

    #2312371
    David
    Staff
    Customer Support

    Ok, so you can use this filter: generate_navigation_logo

    https://docs.generatepress.com/article/generate_navigation_logo/

    with the get_avatar_url function:

    https://developer.wordpress.org/reference/functions/get_avatar_url/

    Which results in a PHP Snippet that you can add to your site:

    add_filter( 'generate_navigation_logo','lh_category_navigation_logo' );
    function lh_category_navigation_logo( $logo ) {
        $logo = get_avatar_url( 'your_user_email' ,['size' => '80'] ); 
    
        return $logo;
    }

    In the get_avatar_url function you will see the first field requires an ID or user email, so the 'your_user_email' needs updating in the function. And set the size in pixels that you need the image to display.

    One thing to note – this will require a 3rd party request being made to the gravatar servers which can lead to a delay in that image being first displayed.

    #2312682
    Arp

    Thanks David!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.