Make WordPress Core

Opened 7 years ago

Closed 5 years ago

#16976 closed defect (bug) (wontfix)

Don't use photo as avatar class in comments

Reported by: Okoth1 Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.5
Component: Comments Keywords: 2nd-opinion
Focuses: Cc:


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 (2)

#1 @dd32
7 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)

#2 @dd32
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed
  • Version changed from 3.1 to 2.5

Unfortunately, as much as I agree that 'photo' is a badly generic class that shouldn't have been used here, there's over 5 years worth of sites which have been potentially using it's styling.

For backwards compatibility purposes, we can't remove it now, but themes can use code similar to the above to change it.

Note: See TracTickets for help on using tickets.