Skip to:
Content
Pages
Categories
Search
Top
Bottom

alt attribute missing for bing search


  • Clivesmith
    Participant

    @clivesmith

    Hi,
    On a topic or reply we show an avatar for the person posting, however the icon used does not have an “alt” description so bing scan shows it as a warning which can affect the rankings. this is the item.
    <span class=”bbp-author-avatar”>
    <img class=”avatar avatar-80 photo” alt=”” src=”https://secure.gravatar.com/avatar/e0808c8f2212a025baef38966c3484e4?s=80&d=mm&r=g&#8221; srcset=”https://secure.gravatar.com/
    avatar/e0808c8f2212a025baef38966c3484e4?s=160&d=mm&r=g 2x” height=”80″ width=”80″ loading=”lazy” decoding=”async”>
    </span>
    Is the a way to globally add an alt description even if it is only “avatar icon” ?

Viewing 4 replies - 1 through 4 (of 4 total)

  • Robin W
    Moderator

    @robin-w

    I think this does what you want

    add_filter ('bbp_get_reply_author_avatar', 'rew_avatar', 10 , 3) ;
    add_filter ('bbp_get_topic_author_avatar', 'rew_avatar' , 10 , 3) ;
    
    function rew_avatar ( $author_avatar, $id, $size)  {
    	if ( bbp_is_reply( $id ) ) {
    		$author = bbp_get_reply_author_display_name( $id );
    		$text = 'alt="icon avatar for '.$author.'"' ; 
    	}
    	if ( bbp_is_topic( $id ) ) {
    		$author = bbp_get_topic_author_display_name( $id );
    		$text = 'alt="icon avatar for '.$author.'"' ; 
    	}
    	$author_avatar = str_replace('alt=\'\'',$text,$author_avatar);
    return $author_avatar ;
    }

    Clivesmith
    Participant

    @clivesmith

    Hi Robin,
    That looks great, I will try it.
    Thank you
    Clive


    Clivesmith
    Participant

    @clivesmith

    Hi Robin,
    Works great, thank you


    Robin W
    Moderator

    @robin-w

    🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar