Opened 2 years ago

Last modified 2 years ago

#16976 new defect (bug)

Don't use photo as avatar class in comments

Reported by: Okoth1 Owned by:
Priority: normal Milestone: Awaiting Review
Component: Comments Version: 3.1
Severity: normal Keywords: 2nd-opinion
Cc:

Description

If you use an image in your post with class 'photo' to show it in Google's search results as a rich snippet is not possible if you make use of avatars in your comments. Google will pick the last class 'photo' image on the page to show as the search result.

Suggestion is to change the avatar class in comments to from 'photo' to 'comment-photo'. A post image is more important than a comment avatar to use for rich snippets.

Change History (1)

comment:1   dd322 years ago

  • Keywords 2nd-opinion added

Just removing the class has the problem that people currently styling that class will lose out.

Also, These are hCard classes, see #8264 for where it was implemented.

You could do something such as this if you care enough:

add_filter('get_avatar', 'remove_photo_class');
function remove_photo_class($avatar) {
    return str_replace(' photo', ' comment-photo', $avatar);
}

(That is a wide-ranging replace there, but it's the most simplistic based on the fact ' photo' shouldn't be anywhere else in that string if you're using the default Gravatar avatar system)

Note: See TracTickets for help on using tickets.